1. Carbohydrate 2. Protein 3. Fat Please enter your choice>> 2 1. Low 2. Moderate 3. High Please enter your choice>> 3 List of cereal (s) with high amount of protein: 1. Cereal B 2. Cereal D Choose again? Y/N >> N Figure 1.2: Screen output Outout on file: The program should duce an outnut the formatting shown in

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Need the flowchart for this question
1. Carbohydrate
2. Protein
3. Fat
Please enter your choice>> 2
1. Low
2. Moderate
3. High
Please enter your choice>> 3
List of cereal (s) with high amount of protein:
1. Cereal B
2. Cereal D
Choose again? Y/N >> N
Type
Figure 1.2: Screen output
(1) Output on file: The program should produce an output file with the formatting shown in
Figure 1.3. The corresponding level (low, moderate, high) for each percentage values also
needs to be displayed, as below.
Carbohydrate
Cereal A
Cereal B
Cereal C
Cereal D
24.9% (high)
3.2% (Low)
24.4% (high)
18.4% (moderate)
Protein
Fat
Protein
14.7% (moderate)
30.1% (high)
15.9% (moderate)
24.9% (high)
The four cereal types produce an average DV of:
Carbohydrate: 18% (moderate)
: 21% (high)
: 13% (moderate)
Fat
15.7% (moderate)
3.0 (low)
27.5% (high)
6.5% (moderate)
Figure 1.3: Output file
(g) Use array (one-dimension or two-dimension) to store the input data from file and the output
data.
(h) The program should be written in several user-defined functions for example
calconvert() function to convert ounce value to gram, calDV () function to
calculate %DV, category(function to categorize each nutrient value, etc. Each function
must be implemented with the concept of parameter passing. Use appropriate arguments
for each function.
Transcribed Image Text:1. Carbohydrate 2. Protein 3. Fat Please enter your choice>> 2 1. Low 2. Moderate 3. High Please enter your choice>> 3 List of cereal (s) with high amount of protein: 1. Cereal B 2. Cereal D Choose again? Y/N >> N Type Figure 1.2: Screen output (1) Output on file: The program should produce an output file with the formatting shown in Figure 1.3. The corresponding level (low, moderate, high) for each percentage values also needs to be displayed, as below. Carbohydrate Cereal A Cereal B Cereal C Cereal D 24.9% (high) 3.2% (Low) 24.4% (high) 18.4% (moderate) Protein Fat Protein 14.7% (moderate) 30.1% (high) 15.9% (moderate) 24.9% (high) The four cereal types produce an average DV of: Carbohydrate: 18% (moderate) : 21% (high) : 13% (moderate) Fat 15.7% (moderate) 3.0 (low) 27.5% (high) 6.5% (moderate) Figure 1.3: Output file (g) Use array (one-dimension or two-dimension) to store the input data from file and the output data. (h) The program should be written in several user-defined functions for example calconvert() function to convert ounce value to gram, calDV () function to calculate %DV, category(function to categorize each nutrient value, etc. Each function must be implemented with the concept of parameter passing. Use appropriate arguments for each function.
The % Daily Value (or %DV) shows how much of a nutrient is in one serving of a packaged
food. The %DVs are based on the values for key nutrients, which are the amounts (in grams)
of nutrients recommended per day for individuals 4 years of age and older. To calculate the
%DV of a packaged food, you have to divide the nutrient amount per serving by the daily
recommended value and multiply by 100. To know whether you are getting enough amount
of a certain nutrient from a packaged food, the following level of categorization applies:
• 5% or less of a nutrient per serving is low
More than 5% but less than 20% of a nutrient per serving is moderate
20% or more of a nutrient per serving is high
Write a complete C program that reads a list of data (cereal type, carbohydrate in ounce, protein
in ounce, fat in ounce) from an input file. Prepare the input file as shown in Figure 1.1 with data
for 10 types of cereal. For the first four types of cereal (Cereal A, B, C, D), use the values as shown
in the figure below. Complete the file for the remaining six types of cereal with your own values.
Cereal A
Cereal B
Cereal C
Cereal D
2.64
0.34
2.58
1.95
0.26
0.53
0.28
0.44
Figure 1.1: Input File
By reading the input file that you have prepared, your program should be able to:
(a) Calculate the conversion of the nutrient values in ounce (oz) into gram (g), with two
decimal places. Note: loz=28.35g
(b) Calculate the %DV of each nutrient (g) for each cereal. Note: The daily recommended
value for all three nutrients are as follows:
Carbohydrate-300g
Protein - 50g
Fat-65g
(c) Calculate the average %DV of Carbohydrate, Protein and Fat for all cereals.
(d) Determine and display the category of each nutrient, either low, moderate or high.
(e) Output on screen: Ask the user to enter choice of nutrient (carbohydrate, protein, fat)
and level (low, moderate, high) and display the food listed under that category (e.g.
Figure 1.2)
0.36
0.07
0.63
0.15
Transcribed Image Text:The % Daily Value (or %DV) shows how much of a nutrient is in one serving of a packaged food. The %DVs are based on the values for key nutrients, which are the amounts (in grams) of nutrients recommended per day for individuals 4 years of age and older. To calculate the %DV of a packaged food, you have to divide the nutrient amount per serving by the daily recommended value and multiply by 100. To know whether you are getting enough amount of a certain nutrient from a packaged food, the following level of categorization applies: • 5% or less of a nutrient per serving is low More than 5% but less than 20% of a nutrient per serving is moderate 20% or more of a nutrient per serving is high Write a complete C program that reads a list of data (cereal type, carbohydrate in ounce, protein in ounce, fat in ounce) from an input file. Prepare the input file as shown in Figure 1.1 with data for 10 types of cereal. For the first four types of cereal (Cereal A, B, C, D), use the values as shown in the figure below. Complete the file for the remaining six types of cereal with your own values. Cereal A Cereal B Cereal C Cereal D 2.64 0.34 2.58 1.95 0.26 0.53 0.28 0.44 Figure 1.1: Input File By reading the input file that you have prepared, your program should be able to: (a) Calculate the conversion of the nutrient values in ounce (oz) into gram (g), with two decimal places. Note: loz=28.35g (b) Calculate the %DV of each nutrient (g) for each cereal. Note: The daily recommended value for all three nutrients are as follows: Carbohydrate-300g Protein - 50g Fat-65g (c) Calculate the average %DV of Carbohydrate, Protein and Fat for all cereals. (d) Determine and display the category of each nutrient, either low, moderate or high. (e) Output on screen: Ask the user to enter choice of nutrient (carbohydrate, protein, fat) and level (low, moderate, high) and display the food listed under that category (e.g. Figure 1.2) 0.36 0.07 0.63 0.15
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY