0

how to write the code that can go back to the menu when I want?

I am making a calculator program. I want to make people continue to work my math program until they choose to exit back to the main menu, but I don't know how.. and I want my program to display the result (how many correct/incorrect for each type of math program) once the program is exited

26th Apr 2017, 3:33 AM
Kurt Cobain
Kurt Cobain - avatar
2 Answers
+ 6
Use a loop. Then exit the loop if the user exits the menu. Rather than a formal loop, I think after you ouput the result of the calculator you should just call the menu function again (That's optional, you could just use a while or do while with a boolean to determine if user wants to exit). So the menu is displayed; for better UI you can use Thread.sleep(x) to add a delay between the menu screen and the result of calculation. Where x * 1000 is seconds to wait.
26th Apr 2017, 4:36 AM
Rrestoring faith
Rrestoring faith - avatar
+ 5
look into finite state machines.
26th Apr 2017, 3:42 AM
jay
jay - avatar