Question: Develop an algorithm and write the html and JavaScript that displays a web page that is titled Math Calculator . Your code should allow the
Develop an algorithm and write the html and JavaScript that displays a web page that is titled "Math Calculator ". Your code should allow the user to enter two numbers through two prompt boxes- then again, through a prompt box, ask the user if they want to add, subtract, multiply, or divide the two numbers. Prompt the user to enter a 1 to add, 2 to subtract, 3 to multiply, or 4 to divide. If a number other 1, 2, 3, or 4 is entered then print an error message (either in an Alert box or in the document window) and exit the program. If a correct number is entered print the two numbers and the arithmetic result in the document window. Then ask the user if they want to perform another set of arithmetic - if the user responds Y or y (for yes ) then loop back up, allow the user to enter two new numbers, and a new operation. Continue till the user enters a character other than Y or y to indicate that they do not want to any more arithmetic calculations to be performed. All of the calculations should be displayed in the document window. And if the user enters a number other 1, 2, 3, or 4 - display an error in an Alert box and give the user 2 more chances to enter a correct number ( 1 through 4). After the user enters the third incorrect response, then exit the program (this requires a loop).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
