Problem

Complete the following tasks:a. Design a Meal class with two fields—one that holds the nam...

Complete the following tasks:

a. Design a Meal class with two fields—one that holds the name of the entrée, the other that holds a calorie count integer. Include a constructor that sets a Meal’s fields with parameters, or uses default values when no parameters are provided.


b. Include an overloaded insertion operator function that displays a Meal’s values.


c. Include an overloaded extraction operator that prompts a user for an entrée name and calorie count for a meal.


d. Include an overloaded operator+()function that allows you to add two or more Meal objects. Adding two Meal objects means adding their calorie values and creating a summary Meal object in which you store “Daily Total” in the entrée field.


e. Write a main()function that declares four Meal objects named breakfast, lunch, dinner, and total. Provide values for the breakfast, lunch, and dinner objects. Include the statement total = breakfast + lunch + dinner; in your program, then display values for the four Meal objects. Save the file as Meal.cpp.


f. Write a main()function that declares an array of 21 Meal objects. Allow a user to enter values for 21 Meals for the week. Total these meals and display the calorie total for the end of the week. (Hint: You might find it useful to create a constructor for the Meal class.) Save the file as Meal2.cpp.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT