Advertisement
vp0415

lec4.3

Oct 31st, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Retail {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner( System.in );
  7.         int number;
  8.         int quantity;
  9.         int choice = 1;
  10.         double total = 0;
  11.  
  12.         while(choice != 2){
  13.             System.out.print("Product number: ");
  14.             number = input.nextInt();
  15.             System.out.print("Quantity sold: ");
  16.             quantity = input.nextInt();
  17.  
  18.             switch(number){
  19.             case 1: total += 2.98*quantity; break;
  20.             case 2: total += 4.5*quantity; break;
  21.             case 3: total += 9.98*quantity; break;
  22.             case 4: total += 4.49*quantity; break;
  23.             case 5: total += 6.87*quantity; break;
  24.             default: System.out.println("error: wrong number of product!"); break;
  25.             }
  26.             System.out.print("To continue enter 1, To show total enter 2: ");
  27.             choice = input.nextInt();
  28.         }
  29.         System.out.print("TOTAL: ");
  30.         System.out.println(total);
  31.     }
  32.  
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement