Guest User

Untitled

a guest
Feb 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 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.  
  34. if (combinedSlices > 12) {
  35. int temp = totalslices % 12;
  36. numberoflarges = ( (totalslices-temp) / 12);
  37. System.out.println(numberoflarges +" large pizza(s) at " + largePrice);
  38. totalslices = temp;
  39. totalCost += (numberoflarges * largePrice);
  40.  
  41. if (totalslices>= 6) {
  42. temp = totalslices % 6;
  43. numberofmeds = ( (totalslices-temp) / 6);
  44. System.out.println(numberofmeds + " medium pizza(s) at " + mediumPrice);
  45. totalslices = temp;
  46. totalCost += (numberofmeds * mediumPrice );
  47. }
  48. if (totalslices >= 4) {
  49. temp = totalslices% 4;
  50. numberofsmalls = ( (totalslices-temp) / 4);
  51. System.out.println(numberofsmalls +" small pizza(s) at " + smallPrice);
  52. totalslices = temp;
  53. totalCost += (numberofsmalls * smallPrice );
  54. }
  55. System.out.println();
  56. System.out.println("This order includes " + combinedSlices + " slices which means there will be " + totalslices + " extra slice(s).");
  57.  
  58.  
  59.  
  60. System.out.println("Your order comes to $" + totalCost);
  61. }
  62. }
  63. }
Add Comment
Please, Sign In to add comment