Hello,
I have been working on this program for the past four hours and was doing good till I got to this point. I am pretty sure that I probably can't do it this way, but I'm just learning and it isn't becoming apparent to me how to correct it. Any help would be appreciated. I apologize in advance if the code wrap did not work properly.
#include<iostream>
#include<cmath>
//Global Variables and Function declarations
double bmr(double P);//BMR = Basal Metabolic rate. This function declaration is for the first function.
double pa(double intensity, double P, double time);//PA = Physical Activity. This function declaration is for the second function.
double eda(double fav_food);//EDA = Energy to Digest food. This function declaration is for the third function.
double mcw(double cals_con, double bmr, double pa, double eda);//MCW = Maintaining current weight. This function declaration is for the fourth function.
int main()
{
using namespace std;
char rerun;
do
{
//This is the section where the variables will be declared for the program.
double P;//P = pounds
double intensity;
double time;
double cals_con;
double servings;
//This is the prompt area asking the user for the information needed to operate the program.
cout << "\n\nPlease enter your weight: ";
cin >> P;
cout << "\nPlease enter the estimated intensity between 1 and 20 of your activity: ";
cin >> intensity;
cout << "\nPlease enter the amount of time (in minutes) spent doing your activity: ";
cin >> time;
cout << "\nPlease enter the amount of calories from your favorite food: ";
cin >> cals_con;
cout << "\nPlease enter the number of servings of your favorite food: ";
cin >> servings;
//These are the statements giving the user the requested information.
cout << "\nThe calories required for basic Basal Metobolic Rate is: " << bmr(P) << "." << endl;
cout << "\nThe calories required for physical activity are: " << pa(intensity, P, time) << "." << endl;
cout << "\nThe calories required for digestion are: " << eda(cals_con) << "."<< endl;
cout << "\nThe calories required for maintaining body weight: " << mcw(cals_con, pa, bmr, eda) << "." << endl;
cout << "\n Press 'y' if you would like to rerun this program.";
cin >> rerun;
}
while (rerun == 'Y' || rerun == 'y');
return 0;
}
//This is the beginning of the function definitions.
double bmr(double P)//Function definition one.
{
double bmr;
double mid = (P/2.2);//This algorithm is dividing the pounds by 2.2 before moving on to raise it to the power of 0.756.
bmr = 70 * pow(mid, 0.756);//This is the finished algorithm that produces the basal metabolic rate.
return bmr;
}
double pa(double intensity, double P, double time)//Function definition two.
{
double pa;
pa = 0.0385 * intensity * P * time;//This algorithm is used to calculate the calories needed for physical activity.
return pa;
}
double eda(double cals_con)//Function definition three.
{
double eda;
eda = cals_con * 0.1;//This algorithm is used to calculate the calories needed for digestion.
return eda;
}
double mcw(double cals_con, double pa, double bmr, double eda)//This algorithm is used to calculate the calories needed to maintain a body.
{
double mcw;
double servings;
double mid2 = bmr + pa + cals_con + eda;
mcw = (mid2/servings);
return mcw;
}
The errors given are:
In function 'int main()':
Line 46: error: cannot convert 'double (*)(double, double, double)' to 'double' for argument '2' to 'double mcw(double, double, double, double)'
compilation terminated due to -Wfatal-errors.