-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (62 loc) · 1.61 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"strconv"
)
func greet(name, year string) {
fmt.Println("Hello! My name is " + name + ".")
fmt.Println("I was created in " + year + ".")
}
func showName() {
var name string
fmt.Println("Please, remind me your name.")
fmt.Scan(&name)
fmt.Println("What a great name you have, " + name + "!")
}
func guessAge() {
var rem3, rem5, rem7, age int
fmt.Println("Let me guess your age.")
fmt.Println("Enter remainders of dividing your age by 3, 5 and 7.")
fmt.Scan(&rem3, &rem5, &rem7)
age = (rem3*70 + rem5*21 + rem7*15) % 105
fmt.Println("Your age is " + strconv.Itoa(age) + "; that's a good time to start programming!")
}
func count() {
var n int
fmt.Println("Now I will prove to you that I can count to any number you want.")
fmt.Scan(&n)
for i := 0; i <= n; i++ {
fmt.Printf("%d!\n", i)
}
}
func startQuiz() {
var num int
fmt.Println("Let's test your programming knowledge.")
fmt.Println("Why do we use methods?")
fmt.Println("1. To repeat a statement multiple times.")
fmt.Println("2. To decompose a program into several small subroutines.")
fmt.Println("3. To determine the execution time of a program.")
fmt.Println("4. To interrupt the execution of a program.")
fmt.Scan(&num)
switch num {
case 1:
fmt.Println("Please, try again.")
case 2:
fmt.Println("Completed, have a nice day!")
case 3:
fmt.Println("Please, try again.")
case 4:
fmt.Println("Please, try again.")
}
}
func sayGoodbye() {
fmt.Println("Congratulations, have a nice day!")
}
func main() {
greet("Bot", "2022") // change it as you need
showName()
guessAge()
count()
startQuiz()
sayGoodbye()
}