Guest User

Untitled

a guest
Feb 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Eg_Pizza {
  4.  
  5.         public static void main(String[] args)
  6.         {
  7.                 Scanner input = new Scanner(System.in);
  8.  
  9.                 System.out.println("\t**Eric's Pizza Party Planner Program!**");
  10.                 System.out.println("\t  ***********************************\n");
  11.                
  12.                 System.out.print("Enter the total number of people who want pizza: ");
  13.                 int people;
  14.                 people = input.nextInt();
  15.  
  16.                 System.out.print("Enter the number of pizza slices per person: ");
  17.                 int slice;
  18.                 slice = input.nextInt();
  19.                
  20.                 System.out.println();
  21.                
  22.                
  23.                 int combinedSlices = people * slice ;
  24.                 System.out.println("The total number of slices required is " + combinedSlices );
  25.                 System.out.println();
  26.                
  27.                 double smallPrice = 7.95;
  28.                 double mediumPrice = 11.55;
  29.                 double largePrice = 19.35;
  30.                 double totalCost;
  31.         int numberoflarges,numberofmeds,numberofsmalls;
  32.         int totalslices = combinedSlices ;
  33.         totalCost = 0;
  34.        
  35.                 if (combinedSlices > 12) {
  36.                 int temp = totalslices % 12;
  37.                 numberoflarges = ( (totalslices-temp) / 12);
  38.                  System.out.println(numberoflarges +"  large pizza(s) at " + largePrice);
  39.                  totalslices = temp;
  40.                 totalCost += (numberoflarges * largePrice);
  41.                  
  42.                         if (totalslices>= 6) {
  43.                                  temp = totalslices % 6;
  44.                                 numberofmeds = ( (totalslices-temp) / 6);
  45.                                  System.out.println(numberofmeds +  " medium pizza(s) at " + mediumPrice);
  46.                                  totalslices = temp;
  47.                                 totalCost += (numberofmeds * mediumPrice );
  48.                                 }
  49.                                         if (totalslices >= 4) {
  50.                                                  temp = totalslices% 4;
  51.                                                 numberofsmalls = ( (totalslices-temp) / 4);
  52.                                                 System.out.println(numberofsmalls +"  small pizza(s) at " + smallPrice);
  53.                                                 totalslices = temp;
  54.                                                 totalCost += (numberofsmalls * smallPrice );
  55.                                 }
  56.                                         System.out.println();
  57.                                         System.out.println("This order includes " + combinedSlices + " slices which means there will be " + totalslices + " extra slice(s).");
  58.                                        
  59.                                        
  60.                                        
  61.                                         System.out.println("Your order comes to $" + totalCost);
  62.                 }
  63.        }      
  64. }
Add Comment
Please, Sign In to add comment