Calories from fat and Carbohydrates in C# WITH A WINDOWS FORM A nutritionist who
ID: 3565215 • Letter: C
Question
Calories from fat and Carbohydrates in C# WITH A WINDOWS FORM
A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consumed in a day. Then, she calculates the number of calories that result from the fat, using the following formula:
Calories from Fat = Fat Grams X 9
Next, She calculates the number of calories that result from the carbohydrates using the following formula:
Calories from carbs = Carbs grams x 4
Create an application that will make these calculations. In the application, you should have the following methods:
FatCalories-This method should accept a number of fat grams as an argument and return the number of calories from that amount of fat.
CarbCalories-This method should accept a number of carbohydrates grams as an argument and return the number of calories from that amount of carbohydrates.
Explanation / Answer
#include <iostream>
using namespace std;
void grams (int);
void calories ();
int main ()
{
//Get fat and carb grams
grams ();
//convert to calories
calories ();
//Display results
cout << "Today you consumed ", fatcalories, "calories from fat";
cout << "Today you consumed ", carbcalories, "calories from carbs";
system("pause");
return 0;
}
//Get grams
void grams(int ref value);
{
cout << "Please enter then number ";
cout << "of fat grams you consumed today.";
cin >> fatgrams;
cout << "Please enter then number ";
cout << "of carb grams you consumed today.";
cin >> carbgrams;
}
//conver to calories
void calories (int &num)
{
set fatcalories = fatgrams * 9
set carbcalories = carbgrams * 4
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.