Question: Access the following Java source file: DiscountCost.java using this link. Debug the program and get it running in its current form (using Scanner input/output) Once

Access the following Java source file: DiscountCost.java using this link.

Debug the program and get it running in its current form (using Scanner input/output)

Once the program is debugged, change the input/output strategy to use dialog boxes instead of the Scanner console.

Instead of hard-coding the 0.2 in the code for a 20% discount, declare a final constant identifier to replace the value in the existing calculation.

/ This program calculates the sale price of an / item that is regularly priced at $59, with / a 20 percent discount subtracted. import java.util.Scanner; // Needed for the Scanner class public class Discount { public void main(String() args) { Variables to hold the regular price, the amount of a discount, and the sale price. double regularPrice = 59.0; double salePrice; // Create a Scanner object to read input scanner keyboard = new Scanner(System.input) // Get the regular price System.out.print('Enter regular price: '); regularPrice = key.next(); // Calculate the amount of a 20% discount. discount = regularPrice * 0.20; // Calculate the sale price by subtracting // the discount from the regular price. salePrice - regularPrice - discount; // Display the results. system.println("Regular price: $ + regularprice); system.println(Discount amount $" + discount); system.println("Sale price: $" + total); }

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!