As in A01a, print the results of 5 simple math operations to the screen--only this time get the two numbers from the user each time.
Create a class named UsernameA04 in a file named
Explain briefly to the user what your program is going to do. Then ask the user to enter the first number, and read it in using a
Now print the results of using these two numbers in five different math expressions using the +, -, *, /, and % operators. Don't just print out the result though; also print out what the expression is.
So your final output should now look something like this. (Note how I executed the program twice; the command prompts and java command are not part of the output of the program. The stuff in green here is the input I typed when prompted by the program.)
D:\TA\grading\A04>java ZtomaszeA04 This program performs 5 math operations on two integers. Enter the first number: 7 Enter the second number: 3 7 + 3 = 10 7 - 3 = 4 7 * 3 = 21 7 / 3 = 2 7 % 3 = 1 D:\TA\grading\A04>java ZtomaszeA04 This program performs 5 math operations on two integers. Enter the first number: 9 Enter the second number: -2 9 + -2 = 7 9 - -2 = 11 9 * -2 = -18 9 / -2 = -4 9 % -2 = 1
Your program will probably crash if you enter decimal numbers or Strings instead of integers. At this point, that is okay; we'll soon learn how to prevent this.
What to Submit
Grading [3 points]
|~ztomasze Index :
TA Details: ICS111:
|Last Edited: 10 Sep 2008|
©2008 by Z. Tomaszewski.