janicegutierrez86

done

Aug 19th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.*;
  2. public class java2 {
  3.      static Scanner console = new Scanner(System.in);
  4.     public static void main(String[]args)
  5.     {
  6.    
  7.  
  8.     int quantity,pc,total;
  9.     double price = 0;
  10.    
  11.        
  12.   System.out.println("Product code                 Price");
  13.   System.out.println(" 1                          123.45");
  14.   System.out.println(" 2                          450.95");
  15.   System.out.println(" 3                          1200.50");
  16.   System.out.println(" 4                          670.99");
  17.   System.out.println(" 5                          999.90");
  18.   System.out.println("Input Product code:");
  19.    pc= console.nextInt();
  20.    System.out.println("Input the Quantity:");
  21.    quantity= console.nextInt();
  22.  
  23. switch(pc)
  24. {
  25. case 1: price=123.45;
  26. break;
  27. case 2: price=450.95;
  28. break;
  29. case 3: price=1200.50;
  30. break;
  31. case 4: price=670.99;
  32. break;
  33. case 5: price=999.90;
  34. break;
  35. default : System.out.println("Invalid Product code!");
  36.  
  37. }
  38. total=  (int) (price * quantity);
  39.  
  40. System.out.println("Total:"+total);
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment