Hi everyone,

This will be my first post in the forums! Have an assignment where user has to input number of people at a party, the amount of pizza slices per person and then how many pizzas will it require (large, medium or small pizzas each with 12, 6, and 4 slices respectively) to feed all the people WHILE keeping the number of left-over slices to a minimum of 3. Now, I got the whole program basically up and running but I think my math is wrong, because whenever I attempt to enter test data (number of people 17 and 4 slices per person) the answer come back with only 66 instead of 68 and say that i still have 2 "extra" slices, when in fact I dont. I am missing two. The correct answer should be 70 slices with 2 leftover (because 5 x 12 + 1x6 + 1x4 = 70).

Here is the code:

If anyone can give me a hint, that'd be great! Thanks a lot!import java.util.Scanner; //Importing the Scanner class. public class A_Gray_PizzaPartyMildVers { public static void main(String[] args) { //Display title of program and output to screen System.out.println("Aaron's Pizza Party Planning Program!"); System.out.println("*************************************"); //Create Scanner object Scanner keyinput = new Scanner(System.in); //Declare variables of how many people will be at the party and how many slices they will want each. int numberOfPeople; int numberOfSlices; //Prompt user to input the amount of people at the party that want pizza and how many slices they will each want. System.out.print("\nHow many people at your party would like some pizza: "); numberOfPeople = keyinput.nextInt(); System.out.print("How many slices are being bought per person: "); numberOfSlices = keyinput.nextInt(); //Calculate total number of slices for the people at the party and store in a variable. int slicesNeeded = numberOfPeople * numberOfSlices; System.out.println("\nYou will need " + slicesNeeded + " slices of pizza to feed all these hungry party-goers!"); //Declare + initialize variables for the pizza prices double smallPizzaPrice = 7.99; double mediumPizzaPrice = 11.59; double largePizzaPrice = 19.35; //Declare variables for the number of pizzas per size and the total number of slices of the order int numberOfSmallPizzas; int numberOfMediumPizzas; int numberOfLargePizzas; int totalSlices = slicesNeeded; //Will be used to calculate extra slices by modulus division. double orderCost = 0.00; //Declare + initialize variable of the total cost of the pizza order int temp = 0; //Declare + initialize placeholder variable. //Create nested-if structure to determine how many pizzas of each size will be needed to fulfill slicesNeeded. //Also will calculate costs per total of pizza size (how many of each size of pizza will need to be bought). if (slicesNeeded > 12) { temp = totalSlices % 12; numberOfLargePizzas = ( (totalSlices - temp) / 12); System.out.println("\t" + numberOfLargePizzas +" large pizza(s) at $" + largePizzaPrice); totalSlices = temp; orderCost += (numberOfLargePizzas * largePizzaPrice); if (slicesNeeded >= 6) { temp = totalSlices % 6; numberOfMediumPizzas = ( (totalSlices - temp) / 6); System.out.println("\t" + numberOfMediumPizzas +" medium pizza(s) at $" + mediumPizzaPrice); totalSlices = temp; orderCost += (numberOfMediumPizzas * mediumPizzaPrice); //end medium pizza if if (slicesNeeded >= 4) { temp = totalSlices % 4; numberOfSmallPizzas = ( (totalSlices - temp) / 4); System.out.println("\t" + numberOfSmallPizzas +" small pizza(s) at $" + smallPizzaPrice); totalSlices = temp; orderCost += (numberOfSmallPizzas * smallPizzaPrice); }//end small pizza if } }//end outer if (large pizza) System.out.println("\nYour order will include " + slicesNeeded + " slices which means there will be " + totalSlices + " left-over."); System.out.println("\nYour order comes to $ " + orderCost); }//end main }//end class