import java.util.Scanner;
/*
Q2) A company sells 6 products whose prices are as follow: P1, $10.00; P2, $5.00; P3, $2.25; P4,
$15.65; P5, $42.75; and P6, $24.35. Write an application the reads a series of pairs as follows:
a) Product Number
b) Quantity Sold
The application should use a switch statement to determine the 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 application should stop the loop and display the final results.
*/
public class company {
public static void main (String[] args){
double qs ;
int pn;
double totalqs = 0;
int totalpn = 0;
Scanner input = new Scanner (System.in);
pn = input.nextInt();
while (pn != -1){
switch (pn){
case 1:
qs = input.nextDouble();
totalqs += qs;
break;
case 2:
qs = input.nextDouble();
totalqs += qs;
break;
case 3:
qs = input.nextDouble();
totalqs += qs;
break;
case 4:
qs = input.nextDouble();
totalqs += qs;
break;
case 5:
qs = input.nextDouble();
totalqs += qs;
break;
case 6:
qs = input.nextDouble();
totalqs += qs;
break;
}
totalpn += pn;
pn++;
}
System.out.println("the total of productNumber :");
System.out.println(totalpn);
System.out.printf("the total of Quantity Sold : %.2f ",totalqs);
}
}
/*
1
10.00
2
5.00
3
2.25
4
15.65
5
42.75
6
24the total of productNumber :
-2147483647
the total of Quantity Sold : 22.25
*/مايشتغل الكوووود عدل يعطيني قيم موعدله !!؟؟