In the ChiliToGo program in Exercise 12, the costs to produce an adult meal and a child’s meal are $4.35 and $3.10, respectively. Adult meals are sold for $7.00 and children's meals are sold for $4.00. Modify the ChiliToGo program to display the total profit for each type of meal as well as the grand total profit. An example of the program is shown below: Enter number of adult meals ordered >> 10 Enter number of child meals ordered >> 5 10 adult meals were ordered at 7.0 each. Total is 70.0 5 child meals were ordered at 4.0 each. Total is 20.0 Grand total for all meals is 90.0 Profits: Adult profit is 26.5 Child profit is 4.5 Total profit is 31.0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In the ChiliToGo program in Exercise 12, the costs to produce an adult meal and a child’s meal are $4.35 and $3.10, respectively. Adult meals are sold for $7.00 and children's meals are sold for $4.00. Modify the ChiliToGo program to display the total profit for each type of meal as well as the grand total profit.

An example of the program is shown below:

Enter number of adult meals ordered >> 10 Enter number of child meals ordered >> 5 10 adult meals were ordered at 7.0 each. Total is 70.0 5 child meals were ordered at 4.0 each. Total is 20.0 Grand total for all meals is 90.0 Profits: Adult profit is 26.5 Child profit is 4.5 Total profit is 31.0

ChiliToGoProfit.java
1 import java.util.Scanner;
2 class ChiliToGoProfit
3 {
4 public static void main(String[] args) {
// Modify the code below.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34}
35
final double ADULT_PRICE = 7;
CHILD_PRICE = 4;
final double
final double ADULT_COST = 4.35;
final double CHILD_COST = 3.10;
int adultMeals;
int childMeals;
double totalAdult, totalChild, grandTotal;
double adultProfit, child Profit, totalProfit;
Scanner input = new Scanner(System.in);
System.out.print("Enter number of adult meals ordered >> ");
adultMeals = input.nextInt ();
System.out.print("Enter number of child meals ordered >> ");
childMeals = input.nextInt();
totalAdult = adultMeals * ADULT_PRICE;
totalChild = childMeals * CHILD_PRICE;
grandTotal = totalAdult + totalChild;
adultProfit = ADULT_PRICE - ADULT_COST;
childProfit = CHILD_PRICE - CHILD_COST;
totalProfit = adultProfit + childProfit;
System.out.println(adultMeals + "adult meals were ordered at " + ADULT_PRICE + " each.");
Total is " + totalAdult);
11
System.out.println(childMeals + child meals were ordered at " + CHILD_PRICE + " each.");
Total is " + totalChild);
System.out.println("
System.out.println("
System.out.println("Grand
System.out.println("
System.out.println("
System.out.println("Total
total for all meals is " + grandTotal);
Adult profit is " + adultProfit);
Child profit is " + childProfit);
profit is " + totalProfit);
Transcribed Image Text:ChiliToGoProfit.java 1 import java.util.Scanner; 2 class ChiliToGoProfit 3 { 4 public static void main(String[] args) { // Modify the code below. 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34} 35 final double ADULT_PRICE = 7; CHILD_PRICE = 4; final double final double ADULT_COST = 4.35; final double CHILD_COST = 3.10; int adultMeals; int childMeals; double totalAdult, totalChild, grandTotal; double adultProfit, child Profit, totalProfit; Scanner input = new Scanner(System.in); System.out.print("Enter number of adult meals ordered >> "); adultMeals = input.nextInt (); System.out.print("Enter number of child meals ordered >> "); childMeals = input.nextInt(); totalAdult = adultMeals * ADULT_PRICE; totalChild = childMeals * CHILD_PRICE; grandTotal = totalAdult + totalChild; adultProfit = ADULT_PRICE - ADULT_COST; childProfit = CHILD_PRICE - CHILD_COST; totalProfit = adultProfit + childProfit; System.out.println(adultMeals + "adult meals were ordered at " + ADULT_PRICE + " each."); Total is " + totalAdult); 11 System.out.println(childMeals + child meals were ordered at " + CHILD_PRICE + " each."); Total is " + totalChild); System.out.println(" System.out.println(" System.out.println("Grand System.out.println(" System.out.println(" System.out.println("Total total for all meals is " + grandTotal); Adult profit is " + adultProfit); Child profit is " + childProfit); profit is " + totalProfit);
Expert Solution
Step 1

Modified CODE is given below

 

Inline comments are given for your explanation

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education