Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Retail {
- public static void main(String[] args) {
- Scanner input = new Scanner( System.in );
- int number;
- int quantity;
- int choice = 1;
- double total = 0;
- while(choice != 2){
- System.out.print("Product number: ");
- number = input.nextInt();
- System.out.print("Quantity sold: ");
- quantity = input.nextInt();
- switch(number){
- 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("error: wrong number of product!"); break;
- }
- System.out.print("To continue enter 1, To show total enter 2: ");
- choice = input.nextInt();
- }
- System.out.print("TOTAL: ");
- System.out.println(total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement