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") + } +}