Question
Problem: Your friends are trying to lose weight and build muscle and want to calculate some statistics about their daily food intake. Write a C++
Problem: Your friends are trying to lose weight and build muscle and want to calculate some statistics about their daily food intake. Write a C++ program that will calculate these statistics.
There are three main macronutrients: carbohydrates, fat, and protein.
1 gram of carbohydrate is 4 calories., 1 gram of fat is 9 calories., 1 gram of protein is 4 calories.
Input: The user should be prompted to input the amount of carbohydrates, fat, and protein in grams consumed that day. These will be whole numbers.
Processing: Your friends want to know: the total number of grams consumed and the total number of calories consumed. They also want to know the percent of total calories contributed by each of the macronutrients. For example, if 800 calories are from carbohydrate, 800 calories are from fat, and 400 calories are from protein, then 40% were from carbohydrate, 40% were from fat, and 20% were from protein. And finally, they want to know the Protein:Energy Ratio. This is the number of grams of protein divided by the sum of the number of grams of fat and carbohydrate.
Output: The program should print the statistics described above. All output should be clearly labeled and percentages should include a percent sign (%). Percentages and the Protein:Energy Ratio should be formatted to exactly 1 decimal place.
Problem: Your friends are trying to lose weight and build muscle and want to calculate some statistics about their daily food intake. Write a C++ program that will calculate these statistics. There are three main macronutrients: carbohydrates, fat, and protein. Each gram of carbohydrate is 4 calories. Each gram of fat is 9 calories. Each gram of protein is 4 calories. Input: The user should be prompted to input the amount of carbohydrates, fat, and protein in grams consumed that day. These will be whole numbers. Processing: Your friends want to know: the total number of grams consumed and the total number of calories consumed. They also want to know the percent of total calories contributed by each of the macronutrients. For example, if 800 calories are from carbohydrate, 800 calories are from fat, and 400 calories are from protein, then 40% were from carbohydrate, 40% were from fat, and 20% were from protein. And finally, they want to know the Protein:Energy Ratio. This is the number of grams of protein divided by the sum of the number of grams of fat and carbohydrate. Output: The program should print the statistics described above. All output should be clearly labeled and percentages should include a percent sign (%). Percentages and the Protein:Energy Ratio should be formatted to exactly 1 decimal place. Sample output: Please enter the amount of carbohydrate in grams: 200 Please enter the amount of fat in grams: 90 Please enter the amount of protein in grams: 100 Total Grams : 390 Total Calories : 2010 Percent of calories from each macronutrient: Carbohydrate: 39.8% Fat: 40.3% Protein: 19.9% Protein: Energy Ratio : 0.3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started