From 9964aa916e8754c84b752ff9ebfb69cb3260667c Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 22 Jan 2024 14:02:07 +0100 Subject: [PATCH] Added Golangr exercise I'm gonna be picking up exercises from wherever I can manage to find on the Internet, I'm still too green to start a personal project since I still haven't dipped my toes in more advanced things like real error handling and OS/Network interaction --- golangr/README.md | 4 ++++ golangr/between-1-10-checker/main.go | 35 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 golangr/README.md create mode 100644 golangr/between-1-10-checker/main.go diff --git a/golangr/README.md b/golangr/README.md new file mode 100644 index 0000000..092c3b1 --- /dev/null +++ b/golangr/README.md @@ -0,0 +1,4 @@ +# Golangr exercises + +These are just exercises I pulled from [this website](https://golangr.com/exercises) to practice, I may also do the +same with other websites diff --git a/golangr/between-1-10-checker/main.go b/golangr/between-1-10-checker/main.go new file mode 100644 index 0000000..d125517 --- /dev/null +++ b/golangr/between-1-10-checker/main.go @@ -0,0 +1,35 @@ +package main + +import "fmt" + +var num float64 +var name string + +func main() { + nameget() + + startup(num) + + compare(num) +} + +func startup(number float64) { + fmt.Printf("Alright %s, give me a number, I will tell you if it's between 1 and 10\n", name) + fmt.Printf("Number: ") + fmt.Scan(&num) + return +} + +func nameget() { + fmt.Println("Welcome to this simple program, may I know your name?\n(Please don't use spaces, I still haven't figured out how to parse them all together into a string)") + fmt.Printf("Name: ") + fmt.Scanln(&name) +} + +func compare(number float64) { + if number >= 1 && number <= 10 { + fmt.Printf("The number is between 1 and 10\n") + } else { + fmt.Printf("The number isn't between 1 and 10\n") + } +}