I am working on my first project for K-State and its a fundamentals class but I'm a little rusty on my programming and haven't worked with Java much. In the second part we calculate how many pizzas to order for a lan party and assume there a couple constants like how many slices per pizza(20) and how many slices each person will eat(2) and right now I am trying to have it round up a double to calculate the number of pizzas needed. I just can't get it to work properly and I know I'm doing something wrong I just don't know what. So if there were 18 people attending, 18 * 2 = 36. We would need 2 pizzas because each one has 20 slices. So the math that I am trying to do is (18 * 2) / 20 so you would get 1.8, I would like this number to be rounded up to 2 so that I can store it and use it to display and calculate how many slices are left over.
/*
Proj1.java
Tristan Stevens / Thursday 6:00pm / Khan
Calculates user's overall grade percentage and how many pizzas to order/slices leftover
*/
import java.util.*;
import java.lang.*;
public class Proj1
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
String input = "";
final double Total = 290;
double Grade = 0.0;
double Points = 0.0;
System.out.print("Enter in Project score #1 (0-30): ");
input = s.nextLine();
Points = Points + Double.parseDouble(input);
System.out.print("Enter in Project score #2 (0-30): ");
input = s.nextLine();
Points = Points + Double.parseDouble(input);
System.out.print("Enter in Project score #3 (0-30): ");
input = s.nextLine();
Points = Points + Double.parseDouble(input);
System.out.print("\n");
System.out.print("Enter the midterm exam score (0-100): ");
input = s.nextLine();
Points = Points + Double.parseDouble(input);
System.out.print("Enter the final exam score: (0-100): ");
input = s.nextLine();
Points = Points + Double.parseDouble(input);
Grade = (Points / Total) * 100;
String output = String.format("Overall grade percentage: %.2f", Grade);
System.out.println(output + "%");
System.out.print("\n");
int People = 0;
final int slicesPeople = 2;
final int slicesPizza = 20;
System.out.print("What is the number of people expected at the pizza party? ");
input = s.nextLine();
People = Integer.parseInt(input);
System.out.print("\n");
double Pizzas = 0.0;
Pizzas = Math.ceil((slicesPeople * slicesPizza) / slicesPizza);
int slicesLeft = 0;
System.out.format("For %d people, that would be %d pizza(s) with each having %d slices each." , People, Pizzas, slicesPeople);
System.out.print("\n");
System.out.format("There would be %d slice(s) leftover.", ((slicesPizza * Pizzas) - (People * slicesPeople)));
System.out.print("\n");
System.out.print("\n");
System.out.print("\n");
}
}