I have an assignment for a class and I missed a day so I am having trouble with an assignment. I need to make a calculator using a prompt that can solve a simple math equation (+,-,/,*) with any number, and it has to use the while loop (and possible do or for or all three). I don't even really know how to start it so any help would be great!
This is the assignment if it helps:
Create a calculator that prompts the user for a simple expression (4+233, 14-2, 4/24, 33.5*33) and then gives the correct result.
The calculator should loop indefinitely until the user enters just # in for their equation
I donít expect any further error checking, assume the user will follow the instructions
The user may enter in numbers of any size and any one of the basic 4 math expressions +-/*, no spaces will be entered nor do they need to be checked for
You will need to ensure the user doesnít try to divide by zero!
HINT1: Use loops to walk through the input string and use if statements to split the string up into the three different sections (first number, expression, second number)
HINT2: Use a switch structure to determine which mathematical operation to run
Take your time and put effort into making your input and output user friendly. Create a nice welcome message that states the restrictions. Have the results nicely formatted as well (see demo in class). When the program is done being ran, have a goodbye message.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)