I need help completed Chapter 7 Programming exercise 2 code
I need help completed Chapter 7 Programming exercise 2 code and chart for Starting out with Programming Logic edition 4
this is what I have so far and as I check it, says need to initialize fatgrams:
//Constant LOW_FAT = 0.3
//Main module
Module main()
//Local variables
Declare Real fatgrams, calories
//Get the number of fat grams
Call getFatGrams(fatgrams)
//Get the number of calories
Call getCalories(calories)
//Calculate the percentage of calories that come from fat. //Percentage of calories from fat = (fatGrams*9) / Calories
Call caloriesPercentage
//Display percentage
Call displayPercentage(percentage)
End Module
Solution
#include<iostream>
using namespace std;
double getFatGrams(double);
double getCalories(double);
double caloriesPercentage(double,double);
void displayPercentage(double);
float LOW_FAT = 0.3;
int main(){
double fatgram,calories,fat;
fatgram = getFatGrams(fatgram);
calories = getCalories(calories);
fat = caloriesPercentage(fatgram,calories);
displayPercentage(fat);
return 0;
}
double getFatGrams(double fatgrams){
//do the required operation and return the fatgrams
}
double getCalories(double calories){
//do the required operation and return the calories
}
double caloriesPercentage(double fatgram,double calories){
double fat = (fatgram*9) / calories;
return fat;
}
void displayPercentage(double percentage){
cout<<\"The percentage of calories are: \"<<percentage;
}

