diff --git a/questions.go b/questions.go new file mode 100644 index 0000000..e69de29 diff --git a/tut.go b/tut.go new file mode 100644 index 0000000..8ceb2b4 --- /dev/null +++ b/tut.go @@ -0,0 +1,71 @@ +package main + +import "fmt" // fmt is a package that contains basic functionality like printing to the terminal and taking in user input + +/* + CLI_Trivia. + +This is a short Kingdom Hearts trivia game played on the command line. +*/ +func main() { + /* Welcome message. + Println prints a welcome message to the terminal and appends a \n at the end of the line + */ + fmt.Println("¡Bienvenidos a Kingdom Hearts Trivia!") + + /* What is your name?. + Print will prompt you to enter your name */ + fmt.Print("¿Cual es tu nombre?: ") + var name string //this variable holds your name. you have to type variables in go. + + fmt.Scan(&name) //Scan will let you type your name in. "&" is an operator used to retrieve the memory address of name. the user's input will save to the "name" variable. + fmt.Printf("¡WEPA, %v, por fin llegaste!\n", name) //Printf will print the formatted name variable and display a greeting to the user with their name + + /* Age Check. + P*/ + fmt.Print("¿Este juego esta clasificado para mayores de 10 años. Cuantos años tienes?: ") + var age uint + + fmt.Scan(&age) + + if age >= 10 { + fmt.Println("Puedes jugar (=") + } else { + fmt.Println("No puedes jugar )=") + return + } + + score := 0 + num_quest := 2 + fmt.Printf("Where are Sora, Riku, and Kairi from? ") + + var q1ans string + var q1ans2 string + + fmt.Scan(&q1ans, &q1ans2) + if q1ans+" "+q1ans2 == "Destiny Islands" { + fmt.Println("Correct!") + score++ + } else if q1ans+" "+q1ans2 == "destiny islands" { + fmt.Println("Correct!") + } else { + fmt.Println("Wrong!") + + } + + fmt.Printf("How many worlds did Sora explore in KH2? ") + var worlds uint + fmt.Scan(&worlds) + + if worlds == 16 { + fmt.Println("Correct!") + score++ + } else { + fmt.Println("Wrong!") + } + + fmt.Printf("You scored %v out of %v \n", score, num_quest) + + percent := (float64(score) / float64(num_quest)) * 100 + fmt.Printf("You scored: %v%%. \n", percent) +}