Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Eg_Pizza {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- System.out.println("\t**Eric's Pizza Party Planner Program!**");
- System.out.println("\t ***********************************\n");
- System.out.print("Enter the total number of people who want pizza: ");
- int people;
- people = input.nextInt();
- System.out.print("Enter the number of pizza slices per person: ");
- int slice;
- slice = input.nextInt();
- System.out.println();
- int combinedSlices = people * slice ;
- System.out.println("The total number of slices required is " + combinedSlices );
- System.out.println();
- double smallPrice = 7.95;
- double mediumPrice = 11.55;
- double largePrice = 19.35;
- double totalCost;
- int numberoflarges,numberofmeds,numberofsmalls;
- int totalslices = combinedSlices ;
- if (combinedSlices > 12) {
- int temp = totalslices % 12;
- numberoflarges = ( (totalslices-temp) / 12);
- System.out.println(numberoflarges +" large pizza(s) at " + largePrice);
- totalslices = temp;
- totalCost += (numberoflarges * largePrice);
- if (totalslices>= 6) {
- temp = totalslices % 6;
- numberofmeds = ( (totalslices-temp) / 6);
- System.out.println(numberofmeds + " medium pizza(s) at " + mediumPrice);
- totalslices = temp;
- totalCost += (numberofmeds * mediumPrice );
- }
- if (totalslices >= 4) {
- temp = totalslices% 4;
- numberofsmalls = ( (totalslices-temp) / 4);
- System.out.println(numberofsmalls +" small pizza(s) at " + smallPrice);
- totalslices = temp;
- totalCost += (numberofsmalls * smallPrice );
- }
- System.out.println();
- System.out.println("This order includes " + combinedSlices + " slices which means there will be " + totalslices + " extra slice(s).");
- System.out.println("Your order comes to $" + totalCost);
- }
- }
- }
Add Comment
Please, Sign In to add comment