java programming: you have been requested by a restaurant to track 3 of their di
ID: 3560779 • Letter: J
Question
java programming: you have been requested by a restaurant to track 3 of their dishes. you talk to the chef and determine the following is required:
1. Data: (These must be entered for each dish)
Name of Dish
Quantity of Main Ingredient (in ounces)
Dish's Quantity of Liquid (in ounces)
Cost of Preparing Dish
2. Calculate the size of Pot (in quarts) necessary to cook dish (3 calculations)
Size of Pot (in quarts) = (Quantity of Liquid + Quantity of Main Ingredient)/32 ounces
3. Calculate the Average cost per meal (1 calculation)
Average Cost Per Dish = Sum of Costs Per Dish/Number of Dishes Entered
4. Categorize the size of the Pot needed for the 3 dishes according to the following: (if statement)
a. If Pot is < 1 quart then it is Small
b. If Pot is < 4 quarts then it is Medium
c. If Pot is < 12 quarts then it is Large
d. If Pot is >= 12 quarts then it is Extra Large
5. Calculate the restaurant
Explanation / Answer
import java.util.*;
class DishMaker
{
public static void main(String[] args)
{
// 1. Data: (These must be entered for each dish)
double Sum_of_dishes=0;
int number_of_dishes=0;
double main_ounces = 0;
Scanner in = new Scanner(System.in);
String[] name=new String[100];
// Name of Dish
double[] quantity=new double[100];
// Quantity of Main Ingredient (in ounces)
double[] quantity_of_liquid=new double[100];
// Dish's Quantity of Liquid (in ounces)
double[] cost=new double[100];
// Cost of Preparing Dish
String[] size=new String[100];
while(true)
{
System.out.println("Enter the name of Dish (Enter none to stop) :");
name[number_of_dishes] = in.nextLine();
if(name[number_of_dishes].equalsIgnoreCase("none")) break;
System.out.println("Enter Quantity of Main Ingredient (in ounces) : ");
quantity[number_of_dishes] = in.nextDouble();
main_ounces = main_ounces + quantity[number_of_dishes];
System.out.println("Enter Dish's Quantity of Liquid (in ounces) : ");
quantity_of_liquid[number_of_dishes] = in.nextDouble();
System.out.println("Cost of Preparing Dish : ");
cost[number_of_dishes] = in.nextDouble();
// 2. Calculate the size of Pot (in quarts) necessary to cook dish (3 calculations)
// Size of Pot (in quarts) = (Quantity of Liquid + Quantity of Main Ingredient)/32 ounces
// 4. Categorize the size of the Pot needed for the 3 dishes according to the following: (if statement)
// a. If Pot is < 1 quart then it is Small
// b. If Pot is < 4 quarts then it is Medium
// c. If Pot is < 12 quarts then it is Large
// d. If Pot is >= 12 quarts then it is Extra Large
// 5. Calculate the restaurant
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.