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
This commit is contained in:
parent
a78392d3b3
commit
9964aa916e
|
@ -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
|
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue