janicegutierrez86

new

Aug 19th, 2012
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 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;  
  9.     int A,B;
  10.     String choices;
  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.  
  19.  
  20.  
  21.     System.out.println(" Enter the product code: ");
  22.     code = console. nextDouble();
  23.     System.out.println("Enter the number of items sold: ");
  24.     numsold = console. nextDouble();
  25.     System.out.println("Choose what transaction you prefer");
  26.     System.out.println("A. Determine the retail price of each product");
  27.     System.out.println("B. Calculate the total price sold");
  28.     choices =console. nextLine();
  29.             switch (choices)    {
  30.  
  31.                 case "A":
  32.                     if (code == 1) {
  33.             System.out.println("The retail price is: 123.45");
  34.         }
  35.                     if (code == 2) {
  36.             System.out.println("The retail price is: 450.95");
  37.         }
  38.                     if (code == 3) {
  39.             System.out.println("The retail price is: 1200.50");
  40.         }
  41.                     if (code == 4) {
  42.             System.out.println("The retail price is: 670.99");
  43.         }
  44.                     if (code == 5) {
  45.             System.out.println("The retail price is: 999.90");
  46.         }
  47.                     else {
  48.                 System.out.println("None of the choices");
  49.         }
  50.                 case "B":
  51.                     tps= numsold*(price=code);
  52.                     System.out.println("The total is:"+tps);
  53.                    
  54.                                
  55.                    
  56.  
  57.    
  58.    
  59.            
  60.    
  61.    
  62. }
  63.             }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment