void functions

i started learning about void functions and i want to make sure i do my homework right.
i need to modify a program so that it uses 2 void functions. one to determine fat calories and the other to determine fat percentage.

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declare variables
int totalCals = 0;
int fatGrams = 0;
int fatCals =0;
double fatPercent = 0.0;

//enter input items
cout << "Total calories: ";
cin >> totalCals;
cout << "Grams of fat: ";
cin >> fatGrams;

//determine whether the data is valid
if (totalCals >= 0 && fatGrams >= 0)
{
//calculate and display the output
fatCals = fatGrams * 9;
fatPercent = static_cast<double>(fatCals)
/ static_cast<double>(totalCals) * 100;

cout << "Fat calories: " << fatCals << endl;
cout << fixed << setprecision(0);
cout << "Fat percentage: " << fatPercent << "%" << endl;
}
else
cout << "Input error" << endl;
//end if

system("pause");
return 0;
} // end of main()

there is my code so far...
void fatCals();
void fatPercent();

i am confused on what goes inside the ()
the () is known as the parameter list. So if fat percent is fatCals / totalCals * 100 then you should write fatPercent() like this:
1
2
3
4
void fatPercent( int fatCals, int totalCals )
{
    cout << ( fatCals /  totalCals) * 100;
}


Is that what you're talking about?
Last edited on
Topic archived. No new replies allowed.