janicegutierrez86

Untitled

Aug 19th, 2012
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class ExerciseNumber5 {
  4.     static Scanner console = new Scanner(System.in);
  5.     public static void main(String[]args)
  6.     {
  7.    
  8.         double numsold,code,tps,price,choices;  
  9.     int A,B;
  10.        
  11.   System.out.println("Product code                 Price");
  12.   System.out.println(" 1                          123.45");
  13.   System.out.println(" 2                          450.95");
  14.   System.out.println(" 3                          1200.50");
  15.   System.out.println(" 4                          670.99");
  16.   System.out.println(" 5                          999.90");
  17.  
  18.  
  19.  
  20.     System.out.println(" Enter the product code: ");
  21.     code = console. nextDouble();
  22.     System.out.println("Enter the number of items sold: ");
  23.     numsold = console. nextDouble();
  24.     System.out.println("Choose what transaction you prefer");
  25.     System.out.println("A. Determine the retail price of each product");
  26.     System.out.println("B. Calculate the total price sold");
  27.     choices =console. nextLine();
  28.             switch (choices)    {
  29.  
  30.                 case 'A':
  31.                     if (code == 1) {
  32.             System.out.println("The retail price is: 123.45");
  33.         }
  34.                     if (code == 2) {
  35.             System.out.println("The retail price is: 450.95");
  36.         }
  37.                     if (code == 3) {
  38.             System.out.println("The retail price is: 1200.50");
  39.         }
  40.                     if (code == 4) {
  41.             System.out.println("The retail price is: 670.99");
  42.         }
  43.                     if (code == 5) {
  44.             System.out.println("The retail price is: 999.90");
  45.         }
  46.                     else {
  47.                 System.out.println("None of the choices");
  48.         }
  49.                 case 'B':
  50.                     tps= numsold*(price=code);
  51.                     System.out.println("The total is:"+tps);
  52.                    
  53.                                
  54.                    
  55.  
  56.    
  57.    
  58.            
  59.    
  60.    
  61. }
  62.             }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment