Answer:
import java.util.Scanner;
public class num6 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter number of guest");
int totalGuest = in.nextInt();
System.out.println("Enter number of slices per guest");
int slicesPerGuest = in.nextInt();
System.out.println("How many Slices are on a pizza");
int slicesPerPizza = in.nextInt(); // Assume each pizza has 5 slices
double pizzasNeeded;
//Calculating the pizza Needed
int totalslicesNeeded = totalGuest * slicesPerGuest;
pizzasNeeded = totalslicesNeeded/slicesPerPizza;
System.out.println(pizzasNeeded);
}
}
Explanation:
In this program User is required to enter values for the variables totalGuest, slicesPerGuest and slicesPerPizza
First calculate the totalSlices needed by totalGuest * slicesPerGuest;
The calculate number of pizzas needed by totalslicesNeeded/slicesPerPizza;