// Write a program that lets the user input a fruit (Apple, Banana, Strawberry).
// Depending on the input, let the program output a fun fact about the fruit.
// Ask the user if he wants to input another fruit, and if so let him do so.
// Think about what kind of variables you need and in which level to write them.
packagemain
import(
"fmt"
"fmt"
"os"
)
funcmain(){
fmt.Println("Hello world!")
prompt()
}
funcprintFact(sstring){
ifs=="a"{
fmt.Println("Some apple varieties such as Pink Pearl and Kissabel have flesh that ranges from pink or orange to bright red.")
}elseifs=="b"{
fmt.Println("Bananas don’t actually grow on trees—they grow on plants that are officially classified as an herb (not surprisingly, the world’s largest herb). They’re in the same family as lilies, orchids, and palms.")
}elseifs=="s"{
fmt.Println("The strawberry is a member of rose family and it is the only fruit which has seeds outside.")
}else{
fmt.Println("Please choose one of [a]pple, [b]anana, or [s]trawberry.")
}
}
funcloop(){
fmt.Print("Would you like to hear another fact? [y/n]: ")
varsstring
fmt.Scanln(&s)
ifs=="y"{
prompt()
}elseifs=="n"{
os.Exit(0)
}else{
fmt.Println("Please enter either [y]es or [n]o.")
}
}
funcprompt(){
fmt.Print("Please select a fruit to hear an interesting fact about ([a]pple, [b]anana, [s]trawberry): ")