Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create a Java application program that will add up the cost of three items, then

ID: 3787265 • Letter: C

Question

create a Java application program that will add up the cost of three items, then print the final total with sales tax.

You should begin by prompting the user to enter three separate prices for three items that are being purchased. For each item you should ask for (in this order) the quantity of the product and the price of the product.

The program should compute, and be able to print to the screen:

the subtotal (the total amount due before tax)

sales tax (the amount of sales tax that will be added, assume 7% tax rate)

total due (subtotal + sales tax)

The following is an example of what your MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The user's values are shown below in italics:

Enter the quantity of the first product: 3
Enter the price of the first product: $5.25
Enter the quantity of the second product: 2
Enter the price of the second product: $1.83
Enter the quantity of the third product: 7
Enter the price of the third product: $0.89

Subtotal: $25.64
Sales Tax: $1.79
Total Due: $27.43

can post a screen shot of your java program Would like to learn the steps, i am doing intro to Java programing

Explanation / Answer

CalCostofThreeItems.java

import java.text.DecimalFormat;
import java.util.Scanner;

public class CalCostofThreeItems {

   public static void main(String[] args) {

       //Declaring the variables
       int quant1,quant2,quant3;
       double price_prod1,price_prod2,price_prod3;
      
       //DecimalFormat class Object is used to Format the output values
       DecimalFormat df=new DecimalFormat("#.##");
      
       //Scanner object is used to get the inputs entered by the user
       Scanner sc=new Scanner(System.in);
         
       //Getting the quantity of first item entered by the user
       System.out.print("Enter the quantity of the first product:");
       quant1=sc.nextInt();
      
       //Getting the price of the first product entered by the user
       System.out.print("Enter the price of the first product: $");
       price_prod1=sc.nextDouble();
      
       //Getting the quantity of second item entered by the user
       System.out.print("Enter the quantity of the second product:");
       quant2=sc.nextInt();

       //Getting the price of the second product entered by the user
       System.out.print("Enter the price of the second product: $");
       price_prod2=sc.nextDouble();  
  
       //Getting the quantity of third item entered by the user
       System.out.print("Enter the quantity of the three product:");
       quant3=sc.nextInt();
      
       //Getting the price of the third product entered by the user
       System.out.print("Enter the price of the three product: $");
       price_prod3=sc.nextDouble();
      
       //Calculating the sub total
       double subTotal=quant1*price_prod1+quant2*price_prod2+quant3*price_prod3;
      
       //calculating the tax
       double tax=(subTotal*7/100);
      
       //calculating the total due
       double total_due=subTotal+tax;
      
       //Displaying the results
       System.out.println(" Subtotal: $"+df.format(subTotal));
       System.out.println("Sales Tax: $"+df.format(tax));
       System.out.println("Total Due: $"+df.format(total_due));
      
   }

}

_________________

output:

Enter the quantity of the first product:3
Enter the price of the first product: $5.25
Enter the quantity of the second product:2
Enter the price of the second product: $1.83
Enter the quantity of the three product:7
Enter the price of the three product: $0.89

Subtotal: $25.64
Sales Tax: $1.79
Total Due: $27.43

_____________Thank You