Question: 2. (Upload as Source File) Write a program which reads in information about a person's diet from a file assume that there is only one

 2. (Upload as Source File) Write a program which reads in
information about a person's diet from a file assume that there is
only one food item in the diet) and displays the information to

2. (Upload as Source File) Write a program which reads in information about a person's diet from a file assume that there is only one food item in the diet) and displays the information to the console screen. The program shall be able to compute the total number of calories that the person consumed Your program shall do the following Functions and Structures: 1) Create 3 variables to represent attributes of the food item. Specifically, a) string Name, ame of the food b) int Quantity Iumber of units consumed c) Int UnitCalories, Il calories per unit 2) Create a function named reodfile which takes references to the three attributes, and a string with the filename as parameters. The function shall read and parse the file and store the information into the attributes it can be assumed the name of the food item will always be one word (hint: getline may not be the optimal method). If the function fails to read the file, the function shall return false Otherwise the function shall return true 8) Create a function named printFoods which takes the three attributes as parameters. The function shall print the contents of the item, e, name, quantity, and calories, to the console. There shall be nothing returned from this function. 4) Create ia named calorieCounter which takes the Quantity and UnitCalories as parameters This function shall compute the total number of calories consumed by multiplying the Quantity with the UnitCalories. The function shall then return the computed calories. There shall be no cin/cout irn this function. 5) Create a function named modityfood which takes references to the three attributes. The function food item. There shall prompt the user to enter in the new name, quantity and unit calories of the shall be no return. Create a function named writefile which the three attributes as parameters. The function shall write the food item into the specified file using the specified format. If the function is successful return back true, otherwise return back false 6) Main Function 1. Declare three variables to store three attributes of the food item. 2. Open the file using the readFile function Detect if the readFile function has encountered an error. If it has, print data instead of quitting an error message and ask user to select "modity first to manually input the Display a menu similar to the one listed in 12:54 PM 10/30/201

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!