105k views
2 votes
To plan a pizza party, one may want to order enough pizza for everyone. Use the slicesPerPizza, slicesPerGuest, and totalGuests variables to compute the total number of pizzas needed to feed all the guests and store the result in pizzasNeeded. The total may have a decimal place.

User Corecase
by
6.8k points

1 Answer

1 vote

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);

}

}

Step-by-step 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;

User Samantha J T Star
by
6.8k points