Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

23:44 { post ull 79% Task 3 Text file food. txt contains partial information about week diet of a very unhealthy person. Each line contains:

image text in transcribed

23:44 { post ull 79% Task 3 Text file food. txt contains partial information about week diet of a very unhealthy person. Each line contains: name of the produce, calories per 100 g of produce (integer), fat per 100 g of produce (float/double), amount of consumed produce in grams [g] (integer) . in the following format: name; calories;fat; amount a. Read the information about the diet into the program. Store the information using a std::vector of structures. Collection should be called weeks_diet. Implemented structure should contain additional fields to store consumed calories and consumed fat. b. Write a function calculate_consumed which will take a weeks_diet collection as a referenced parameter. The function should calculate consumed calories and consumed fat for each produce in collection. Result has to be stored in corresponding fields in a structure. Example call: 1/ weeks_diet contains information only read from file calculate_consumed(weeks_diet); // weeks_diet contains also consumed calories and fat c. Using std::sort algorithm sort produce in weeks_diet based on consumed calories - in ascending order. d. Display all the elements in console in following format: Matt ate X grams of Y, which is: C calories and F grams of fat where: X - amount of produce in grams y-name of produce C-consumed calories F - consumed fat III

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

DISCUSS the drivers and outcomes of each turnover method.

Answered: 1 week ago

Question

=+ a. How does this change affect the incentives for working?

Answered: 1 week ago