Advertisement
Guest User

Untitled

a guest
Sep 28th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.66 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class assgn1 {
  3.  
  4. public static void main (String [] args) {
  5. int x , y, o, p = 0 , pep = 0, cp = 0, chrm = 0, co; // x: is there a customer in line?
  6.                                     // y: are you a Pie card member?
  7.                                     // o: input for "Please Choose an Option"
  8.                                     // p: Plain Pizza input
  9.                                     // pep: Peperoni Pizza input
  10.                                     // cp: Cherry Pie Slices input 
  11.                                     // chrm: Pi Charms input
  12.                                     // co: checkout
  13.  
  14.  double plprice = p * 10.00 , pepprice = pep * 12.00, chprice = cp * 2.00, chrmprice = chrm * 50.00, subtotal = plprice + pepprice + chprice + chrmprice, tax = .06 * subtotal, total = tax + subtotal;
  15.  
  16.         Scanner inScan = new Scanner(System.in);
  17.  
  18. System.out.println("Welcome to Pies, Pies and Pis");
  19. System.out.println("Is there a customer in line? (1 = yes, 2 = no)");
  20. x = inScan.nextInt();
  21. if(x == 1){
  22.     System.out.println("Are you a Pie card member? (1 = yes, 2 = no)");
  23.     y = inScan.nextInt();
  24.  
  25. if(y == 1){
  26.  
  27. System.out.println("Welcome Back, Pie Card holder!:\n" +
  28. "You will receive:\n" + "        Pepperoni pizza for the price of plain\n" +
  29. "        $0.25 off a slice of cherry pie\n" +
  30. "        $2.00 off a whole cherry pie\n" + "        $10.00% off each Pi charm");
  31.  
  32.  
  33. }
  34.  
  35. System.out.println("Please choose an option:\n" +
  36. "   1) Update Pizza Order\n" + "    2) Update Cherry Pie Order\n" +
  37. "   3) Update Charm Order\n" + "    4) Check out");
  38. o = inScan.nextInt();
  39.  
  40. while(o <= 4){
  41.  
  42. switch (o) {
  43.  
  44.     case 1:
  45.     if (p<=0 || pep<=0)
  46.     {
  47.         System.out.println("Here is your current order:\n" + "No pizzas ordered");
  48.         System.out.println("How many plain pizzas would you like for $10.00 each?");
  49.         p = inScan.nextInt();
  50.         System.out.println("How many pepperoni pizzas would you like for $12.00 each?");
  51.         pep = inScan.nextInt();
  52.        
  53.         plprice = p * 10.00;
  54.         pepprice = pep * 10.00;
  55.    
  56.     } else {
  57.         System.out.println("You have ordered" +  p  + "plain pizzas and" +  pep  + "pepperoni pizzas.");
  58.             }
  59.         break;
  60.  
  61.  
  62.     case 2:  
  63.     if (cp<=0)
  64.     {  
  65.         System.out.println("Here is your current order:\n" + "No cherry pie slices ordered");
  66.         System.out.println("How many cherry pie slices would you like for:\n" + "$2.00 per slice\n" +"$10.00 per pie (6 slices)");
  67.         cp = inScan.nextInt();
  68.         chprice = cp * 2.00;
  69.     } else {
  70.         System.out.println("You have ordered" +  cp  + "slices of pie.");
  71.            }
  72.         break;
  73.  
  74.     case 3:
  75.     if (chrm<=0)   
  76.     {  
  77.         System.out.println("Here is your current order:\n" + "No gold Pi charm ordered");
  78.         System.out.println("How many Pi charms would you like for $50.00 each?");
  79.         chrm = inScan.nextInt();
  80.         chrmprice = chrm * 50.00;
  81.        
  82.     } else {
  83.         System.out.println("You have ordered" +  chrm  + "Pi charms.");
  84.             }
  85.         break;
  86.  
  87.     case 4:
  88.         System.out.println("You have ordered" +  p  + "plain pizza(s) and" +  pep  + "pepperoni pizza(s).");
  89.         System.out.println("You have ordered" +  cp  + "slice(s) of pie.");
  90.         System.out.println("You have ordered" +  chrm  + "Pi charm(s).");
  91.         subtotal = plprice + pepprice + chprice + chrmprice;
  92.         System.out.println("Your subtotal is $" + subtotal);
  93.         tax = .06 * subtotal;
  94.         System.out.println("Tax is $" + tax);
  95.         total = tax + subtotal;
  96.         System.out.println("Your total is $" + total);
  97.             break;
  98.  
  99. }
  100.  
  101.         System.out.println("Please choose an option:\n" +
  102. "   1) Update Pizza Order\n" + "    2) Update Cherry Pie Order\n" +
  103. "   3) Update Charm Order\n" + "    4) Check out");
  104. o = inScan.nextInt();
  105.     }
  106.  
  107. }
  108.  
  109. if else (y == 2){
  110.  
  111.  
  112. System.out.println("Please choose an option:\n" +
  113. "   1) Update Pizza Order\n" + "    2) Update Cherry Pie Order\n" +
  114. "   3) Update Charm Order\n" + "    4) Check out");
  115. o = inScan.nextInt();
  116.  
  117. while(o <= 4){
  118.  
  119. switch (o) {
  120.  
  121.     case 1:
  122.     if (p<=0 || pep<=0)
  123.     {
  124.         System.out.println("Here is your current order:\n" + "No pizzas ordered");
  125.         System.out.println("How many plain pizzas would you like for $10.00 each?");
  126.         p = inScan.nextInt();
  127.         System.out.println("How many pepperoni pizzas would you like for $12.00 each?");
  128.         pep = inScan.nextInt();
  129.        
  130.         plprice = p * 10.00;
  131.         pepprice = pep * 12.00;
  132.    
  133.     } else {
  134.         System.out.println("You have ordered" +  p  + "plain pizzas and" +  pep  + "pepperoni pizzas.");
  135.             }
  136.         break;
  137.  
  138.  
  139.     case 2:  
  140.     if (cp<=0)
  141.     {  
  142.         System.out.println("Here is your current order:\n" + "No cherry pie slices ordered");
  143.         System.out.println("How many cherry pie slices would you like for:\n" + "$2.00 per slice\n" +"$10.00 per pie (6 slices)");
  144.         cp = inScan.nextInt();
  145.         chprice = cp * 2.00;
  146.     } else {
  147.         System.out.println("You have ordered" +  cp  + "slices of pie.");
  148.            }
  149.         break;
  150.  
  151.     case 3:
  152.     if (chrm<=0)   
  153.     {  
  154.         System.out.println("Here is your current order:\n" + "No gold Pi charm ordered");
  155.         System.out.println("How many Pi charms would you like for $50.00 each?");
  156.         chrm = inScan.nextInt();
  157.         chrmprice = chrm * 50.00;
  158.        
  159.     } else {
  160.         System.out.println("You have ordered" +  chrm  + "Pi charms.");
  161.             }
  162.         break;
  163.  
  164.     case 4:
  165.         System.out.println("You have ordered" +  p  + "plain pizza(s) and" +  pep  + "pepperoni pizza(s).");
  166.         System.out.println("You have ordered" +  cp  + "slice(s) of pie.");
  167.         System.out.println("You have ordered" +  chrm  + "Pi charm(s).");
  168.         subtotal = plprice + pepprice + chprice + chrmprice;
  169.         System.out.println("Your subtotal is $" + subtotal);
  170.         tax = .06 * subtotal;
  171.         System.out.println("Tax is $" + tax);
  172.         total = tax + subtotal;
  173.         System.out.println("Your total is $" + total);
  174.             break;
  175.  
  176. }
  177.  
  178.         System.out.println("Please choose an option:\n" +
  179. "   1) Update Pizza Order\n" + "    2) Update Cherry Pie Order\n" +
  180. "   3) Update Charm Order\n" + "    4) Check out");
  181. o = inScan.nextInt();
  182.     }
  183.  
  184. }
  185.  
  186. }
  187.  
  188. }
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement