Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Party
- {
- public static void main(String[] args)
- {
- System.out.println("How many people are attending the party?");
- int numPeople = IO.readInt();
- if (numPeople <= 0)
- {
- System.out.println ("This isn't enough people for a party.");
- return;
- }
- if (numPeople > 0)
- {
- System.out.println("How many can of soda will each person drink?");
- int sodaEach = IO.readInt();
- System.out.println("How many cans of soda in each case?");
- int sodaInCase = IO.readInt();
- System.out.println("How much does a case of soda cost?");
- double sodaCost = IO.readDouble();
- double sodaNeeded = (numPeople * sodaEach);
- sodaNeeded = (sodaNeeded / sodaInCase);
- sodaNeeded = Math.ceil(sodaNeeded);
- sodaCost = (sodaNeeded * sodaCost);
- IO.outputDoubleAnswer(sodaNeeded);
- IO.outputDoubleAnswer(sodaCost);
- System.out.println("How many slices of pizza will each person eat?");
- int slicesEach = IO.readInt();
- System.out.println("How many slices in a pie?");
- int slicesInPie = IO.readInt();
- System.out.println("How much does a pizza pie cost?");
- double pizzaCost = IO.readDouble();
- double pizzaNeeded = (numPeople * slicesEach);
- pizzaNeeded = (pizzaNeeded / slicesInPie);
- pizzaNeeded = Math.ceil(pizzaNeeded);
- pizzaCost = (pizzaNeeded * pizzaCost);
- System.out.println(pizzaNeeded);
- System.out.println(pizzaCost);
- System.out.println("Your total cost is:");
- IO.outputDoubleAnswer(sodaCost + pizzaCost);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement