Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1.  
  2. public class Party
  3. {
  4. public static void main(String[] args)
  5. {
  6. System.out.println("How many people are attending the party?");
  7. int numPeople = IO.readInt();
  8.  
  9. if (numPeople <= 0)
  10. {
  11. System.out.println ("This isn't enough people for a party.");
  12. return;
  13. }
  14. if (numPeople > 0)
  15. {
  16. System.out.println("How many can of soda will each person drink?");
  17. int sodaEach = IO.readInt();
  18.  
  19. System.out.println("How many cans of soda in each case?");
  20. int sodaInCase = IO.readInt();
  21.  
  22. System.out.println("How much does a case of soda cost?");
  23. double sodaCost = IO.readDouble();
  24.  
  25. double sodaNeeded = (numPeople * sodaEach);
  26. sodaNeeded = (sodaNeeded / sodaInCase);
  27. sodaNeeded = Math.ceil(sodaNeeded);
  28. sodaCost = (sodaNeeded * sodaCost);
  29. IO.outputDoubleAnswer(sodaNeeded);
  30. IO.outputDoubleAnswer(sodaCost);
  31.  
  32. System.out.println("How many slices of pizza will each person eat?");
  33. int slicesEach = IO.readInt();
  34.  
  35. System.out.println("How many slices in a pie?");
  36. int slicesInPie = IO.readInt();
  37.  
  38. System.out.println("How much does a pizza pie cost?");
  39. double pizzaCost = IO.readDouble();
  40.  
  41. double pizzaNeeded = (numPeople * slicesEach);
  42. pizzaNeeded = (pizzaNeeded / slicesInPie);
  43. pizzaNeeded = Math.ceil(pizzaNeeded);
  44. pizzaCost = (pizzaNeeded * pizzaCost);
  45. System.out.println(pizzaNeeded);
  46. System.out.println(pizzaCost);
  47.  
  48. System.out.println("Your total cost is:");
  49. IO.outputDoubleAnswer(sodaCost + pizzaCost);
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement