making a calculator. I need some help with my code.... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

making a calculator. I need some help with my code....

I was making a calculator, and I could not figure out how to show the results, go back to menu, and set up the sentinel. I cannot use the number variable for sentinel so I used char but it doesn't work.. I seriously need your help guys. Scenario: You will develop a program that will help a child with math. The child will be able to select Addition, Subtraction, Multiplication, or Division as well Exit the program. Once the program is exited the results (How many correct/incorrect for each type of math program) of the session will be displayed. Once the child selects a type (Add, Sub, Mult, Div) the child will continue working with that type of problem until choosing to exit back to main menu. The program will display the math problem, prompt for an answer. The program will notify the child if they are correct or incorrect. If incorrect the correct answer should be displayed by the program. This is my code so far https://code.sololearn.com/cUxAJ3A39326

27th Apr 2017, 7:18 AM
Kurt Cobain
Kurt Cobain - avatar
7 Answers
+ 5
https://code.sololearn.com/cvyZowenT4L3/#java Thats what I have done
27th Apr 2017, 8:19 AM
Meharban Singh
Meharban Singh - avatar
+ 5
Out of topic but why you used c++ tag when you wrote your code in Java
27th Apr 2017, 9:35 AM
Utkαrsh
Utkαrsh - avatar
+ 4
You can make some function like this void menu(){ System.out.println("***** Menu *****"); System.out.println(""); System.out.println("1. Addition"); System.out.println(""); System.out.println("2. Subtraction"); System.out.println(""); System.out.println("3. Multiplication"); System.out.println(""); System.out.println("4. Division"); System.out.println(""); System.out.println("Enter q to exit"); System.out.println(""); System.out.println("***************"); System.out.print("Enter your selection: "); }
27th Apr 2017, 7:22 AM
Nithiwat
Nithiwat - avatar
+ 4
It will not work on sololearns code playground , try somewhere esle.
27th Apr 2017, 7:25 AM
Meharban Singh
Meharban Singh - avatar
+ 4
I am going to redesign it, will take some time thougj.
27th Apr 2017, 7:27 AM
Meharban Singh
Meharban Singh - avatar
+ 4
You can create a function that will wrap parts of the program. Then we can run it several times.
27th Apr 2017, 7:28 AM
Nithiwat
Nithiwat - avatar
+ 4
you should make in the web version :>
27th Apr 2017, 7:29 AM
Nithiwat
Nithiwat - avatar