98 713
Assignments Done
98.6%
Successfully Done
In April 2021

Answer to Question #6853 in Java | JSP | JSF for Prezy Olayo

Question #6853
(calculating Sales) an online retailer sells five products whose retail prices are as follows:
Product 1, $2.98; product 2,$4.50, product 3, $9.98; product 4,$4.49 and product 5, \$6.87.
Write an application tht reads a series of numbers as follows:
a) product number
b) quantatity sold

Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.
1
2012-02-24T10:42:29-0500
package sales;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner( System.in );

int prodNumber, quantity, choice = 1;

double total = 0;

while(choice != 2){

System.out.print(&quot;Product number: &quot;);

prodNumber = in.nextInt();

System.out.print(&quot;Quantity sold: &quot;);

quantity = in.nextInt();

switch(prodNumber){

case 1: total += 2.98*quantity; break;

case 2: total += 4.5*quantity; break;

case 3: total += 9.98*quantity; break;

case 4: total += 4.49*quantity; break;

case 5: total += 6.87*quantity; break;

default:

System.out.println(&quot;error: wrong number of product!&quot;); break;

}

System.out.print(&quot;To continue enter 1, To show total enter 2: &quot;);

choice = in.nextInt();

}

System.out.print(&quot;
TOTAL: &quot;);

System.out.println(total);

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!