Question
using only import java.util.scanner If multiplication is simply a form of iterative addition -- that 4 * 3 is shorthand for 4 + 4 +
using only import java.util.scanner
If multiplication is simply a form of iterative addition -- that 4 * 3 is shorthand for 4 + 4 + 4 -- then what is division? Logically, if integer multiplication is iterative addition, then iteger division must be iterative subrtraction (with a remainder). Using the loop control structure, implement a subtration alternative to the division operation. The specifics are left to the programmer with the restriction that the answer must not employ Java's language-based implementation for either integer operator (ie do not use / or % when developing the arithmetic solution). A typical interation might look like this: Enter two positive intergers for multiplication: 45 9 45 / 9 = 5 with a remainder of 0
Notes:
Develop your solution using Java.
Assume the first integer entered is the dividend and the second is the divisor i.e. from the example above, 45 is the dividend and 9 is the divisor.
Perform appropriate tests to insure user choice meets the criteria. While the Scanner method nextInt() will only accept integer values, test to insure the values entered are greater than zero (0). If the user enters an invalid value, identify the problem with an appropriate error message. Do notperform the arithmetic operation (and do not display a product). The program should display an error message and stop (not attempt to compute the product or prompt for a correct value)
Develop test data and record using an ASCII editor. Match your anticipated responses and the actual responses from the program. The test set should include correct and incorrect data.
After testing with your test data set, record the results as comments at the end of the EC01 source code file.
Submit the source program with the test data set, for credit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started