Don't like ads? PRO users don't see any ads ;-)

done

By: janicegutierrez86 on Aug 19th, 2012  |  syntax: Java  |  size: 1.04 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }