Question: Write a java class that obtains an integer value from a customer that represents the number of photocopies to be printed. Then, calculate and display

Write a java class that obtains an integer value from a customer that represents the number of photocopies to be printed. Then, calculate and display the total job cost. Your "if" test will determine whether or not there are more than 50 copies involved.

You will need to use the DecimalFormat class to obtain the proper number of decimal places shown in the output sample. Review Notes 3. Base your calculations on these rates: the cost for up to and including 50 copies is $0.07 per copy. Copies in excess of 50 copies cost $0.04 per copy, plus the cost of the first 50 at the $0.07 rate. Example: 56 copies would cost .07 x 50 + .04 x 6 = $3.50 + $0.24 = $3.74 (these are the actual numeric results)

Algorithm and coding considerations:

Declare one input-capture variable to store the total number of copies desired. Name it iCopies.

Declare another variable to store the calculated number of copies over 50. Name it iCopiesOver50.

Declare one (and only one) variable named dCost to use as the expression-result variable when calculating cost. It CAN be done: dCost can be accumulated.

Use the if block's true branch for copies <= 50 and the false branch for copies greater than 50.

Output the total cost within each branch (i.e., repeat the output statement in the <= 50 branch as well as the > 50 branch). Using this approach, all the output will occur INSIDE the if block.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!