Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago

Question

Name is needed for identifying organisms ?

Answered: 1 week ago

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago