//Xinnuo Wang CS1A chapter 4, p.223 #16
//
/*******************************************************************************
*
* Caculate Fat Grams
* _____________________________________________________________________________
* This program accepts the number of calories and fat grams and caculates the
* percentage of calories that come from fat
*
* Computation is based on the formula:
* Calories from fat = fat grams * 9
* The percentage of calories = Calories from fat ÷ total calories
* _____________________________________________________________________________
* INPUT
* Total calories : The accepted number of total calories
* Total grams : The accepted number of grams from food
* PROCESS
* Calories from fat : The number of calories from fat
* OUTPUT
* The percentage of calories from fat : The percentage of calories from fat
*
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
double totalGrams; //INPUT - The accepted number of total calories
double totalCalories; //INPUT - The accepted number of total grams
double caloriesFromFat; //PROCESS - The number of calories from fat
double percentageOfCaloriesFromFat; //OUTPUT - The percentage of calories from fat
//
//Data Input
cout << "Enter the number of grams" << endl;
cin>> totalGrams;
cout << "Enter the number of calories" << endl;
cin>> totalCalories;
//
//Caculate Calories from Fat
caloriesFromFat = totalGrams * 9;
//
//Caculate The Percentage of Calories from Fat
percentageOfCaloriesFromFat = caloriesFromFat / totalCalories * 100;
//Output
if(percentageOfCaloriesFromFat< 30)
cout << "The food is low in fat" << endl;
else if(totalGrams<0 && totalCalories< 0)
cout<< "Invalid input" <<endl;
else if(caloriesFromFat>totalCalories)
cout << "either the calories or fat grams were incorrectly entered" <<endl;
return 0;
}