Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class assgn1 {
- public static void main (String [] args) {
- int x , y, o, p = 0 , pep = 0, cp = 0, chrm = 0, co; // x: is there a customer in line?
- // y: are you a Pie card member?
- // o: input for "Please Choose an Option"
- // p: Plain Pizza input
- // pep: Peperoni Pizza input
- // cp: Cherry Pie Slices input
- // chrm: Pi Charms input
- // co: checkout
- 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;
- Scanner inScan = new Scanner(System.in);
- System.out.println("Welcome to Pies, Pies and Pis");
- System.out.println("Is there a customer in line? (1 = yes, 2 = no)");
- x = inScan.nextInt();
- if(x == 1){
- System.out.println("Are you a Pie card member? (1 = yes, 2 = no)");
- y = inScan.nextInt();
- if(y == 1){
- System.out.println("Welcome Back, Pie Card holder!:\n" +
- "You will receive:\n" + " Pepperoni pizza for the price of plain\n" +
- " $0.25 off a slice of cherry pie\n" +
- " $2.00 off a whole cherry pie\n" + " $10.00% off each Pi charm");
- }
- System.out.println("Please choose an option:\n" +
- " 1) Update Pizza Order\n" + " 2) Update Cherry Pie Order\n" +
- " 3) Update Charm Order\n" + " 4) Check out");
- o = inScan.nextInt();
- while(o <= 4){
- switch (o) {
- case 1:
- if (p<=0 || pep<=0)
- {
- System.out.println("Here is your current order:\n" + "No pizzas ordered");
- System.out.println("How many plain pizzas would you like for $10.00 each?");
- p = inScan.nextInt();
- System.out.println("How many pepperoni pizzas would you like for $12.00 each?");
- pep = inScan.nextInt();
- plprice = p * 10.00;
- pepprice = pep * 10.00;
- } else {
- System.out.println("You have ordered" + p + "plain pizzas and" + pep + "pepperoni pizzas.");
- }
- break;
- case 2:
- if (cp<=0)
- {
- System.out.println("Here is your current order:\n" + "No cherry pie slices ordered");
- System.out.println("How many cherry pie slices would you like for:\n" + "$2.00 per slice\n" +"$10.00 per pie (6 slices)");
- cp = inScan.nextInt();
- chprice = cp * 2.00;
- } else {
- System.out.println("You have ordered" + cp + "slices of pie.");
- }
- break;
- case 3:
- if (chrm<=0)
- {
- System.out.println("Here is your current order:\n" + "No gold Pi charm ordered");
- System.out.println("How many Pi charms would you like for $50.00 each?");
- chrm = inScan.nextInt();
- chrmprice = chrm * 50.00;
- } else {
- System.out.println("You have ordered" + chrm + "Pi charms.");
- }
- break;
- case 4:
- System.out.println("You have ordered" + p + "plain pizza(s) and" + pep + "pepperoni pizza(s).");
- System.out.println("You have ordered" + cp + "slice(s) of pie.");
- System.out.println("You have ordered" + chrm + "Pi charm(s).");
- subtotal = plprice + pepprice + chprice + chrmprice;
- System.out.println("Your subtotal is $" + subtotal);
- tax = .06 * subtotal;
- System.out.println("Tax is $" + tax);
- total = tax + subtotal;
- System.out.println("Your total is $" + total);
- break;
- }
- System.out.println("Please choose an option:\n" +
- " 1) Update Pizza Order\n" + " 2) Update Cherry Pie Order\n" +
- " 3) Update Charm Order\n" + " 4) Check out");
- o = inScan.nextInt();
- }
- }
- if else (y == 2){
- System.out.println("Please choose an option:\n" +
- " 1) Update Pizza Order\n" + " 2) Update Cherry Pie Order\n" +
- " 3) Update Charm Order\n" + " 4) Check out");
- o = inScan.nextInt();
- while(o <= 4){
- switch (o) {
- case 1:
- if (p<=0 || pep<=0)
- {
- System.out.println("Here is your current order:\n" + "No pizzas ordered");
- System.out.println("How many plain pizzas would you like for $10.00 each?");
- p = inScan.nextInt();
- System.out.println("How many pepperoni pizzas would you like for $12.00 each?");
- pep = inScan.nextInt();
- plprice = p * 10.00;
- pepprice = pep * 12.00;
- } else {
- System.out.println("You have ordered" + p + "plain pizzas and" + pep + "pepperoni pizzas.");
- }
- break;
- case 2:
- if (cp<=0)
- {
- System.out.println("Here is your current order:\n" + "No cherry pie slices ordered");
- System.out.println("How many cherry pie slices would you like for:\n" + "$2.00 per slice\n" +"$10.00 per pie (6 slices)");
- cp = inScan.nextInt();
- chprice = cp * 2.00;
- } else {
- System.out.println("You have ordered" + cp + "slices of pie.");
- }
- break;
- case 3:
- if (chrm<=0)
- {
- System.out.println("Here is your current order:\n" + "No gold Pi charm ordered");
- System.out.println("How many Pi charms would you like for $50.00 each?");
- chrm = inScan.nextInt();
- chrmprice = chrm * 50.00;
- } else {
- System.out.println("You have ordered" + chrm + "Pi charms.");
- }
- break;
- case 4:
- System.out.println("You have ordered" + p + "plain pizza(s) and" + pep + "pepperoni pizza(s).");
- System.out.println("You have ordered" + cp + "slice(s) of pie.");
- System.out.println("You have ordered" + chrm + "Pi charm(s).");
- subtotal = plprice + pepprice + chprice + chrmprice;
- System.out.println("Your subtotal is $" + subtotal);
- tax = .06 * subtotal;
- System.out.println("Tax is $" + tax);
- total = tax + subtotal;
- System.out.println("Your total is $" + total);
- break;
- }
- System.out.println("Please choose an option:\n" +
- " 1) Update Pizza Order\n" + " 2) Update Cherry Pie Order\n" +
- " 3) Update Charm Order\n" + " 4) Check out");
- o = inScan.nextInt();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement