Prewarning: The Gwin commands are the graphics window we use
Hey, so i have to, create a function called WeightLoss. This function will take as its ONLY
parameter a POINTER to a Patient. The purpose of thefunction is as follows:
If the Patient passed in is male, the function will reduce the Patient's weight by 10%.
If the Patient passed in is female, the function will reduce the Patient's weight by 20%
Code:
#include "stdafx.h"
#include "gwin.h"
#include <fstream>
#include <iostream>
using namespace std;
const int MAXPATIENTS = 10;
const int sex=2;
double bmi[MAXPATIENTS][sex];
double*p=&bmi[MAXPATIENTS][sex];//Problems
struct patient
{
int ID;
double Weight;
double Height;
bool IsMale;
};
double weightLoss (double *p);//Problems line 28
int main()
{
patient dieters[MAXPATIENTS];
int i=0;
ifstream details("Dieters.txt");
Gwin.clear();
Gwin.writeText(10,0,"ID BMI:");
while (i<10)
{
details>>dieters[i].ID>>dieters[i].Weight>>dieters[i].Height>>dieters[i].IsMale;
bmi[i][1]=dieters[i].Weight/(dieters[i].Height*dieters[i].Height);
bmi[i][2]=dieters[i].IsMale;
bmi[i][1]=weightLoss(bmi[i][2]);//Problems
if (bmi[i][1]>22&&dieters[i].IsMale)
{
Gwin.writeInt(0,15*i, dieters[i].ID);
Gwin.writeDouble(40,15*i, bmi[i][1]);
}
else if(bmi[i][1]>25&&!dieters[i].IsMale)
{
Gwin.writeInt(0,15*i, dieters[i].ID);
Gwin.writeDouble(40,15*i, bmi[i][1]);
}
i++;
}
Keyboard.getch();
return 0;
}
int weightLoss(double *p)//Problems
{
int j=j+1;
bool male;
if (bmi[j][2]=male)
{
bmi [j][1]=bmi[j][1]*0.9;
}
else if(bmi[j][2]!=male)
{
bmi[j][1]=bmi[j][1]*0.8;
}
return bmi;
}
cpp(43) : error C2664: 'weightLoss' : cannot convert parameter 1 from 'double' to 'double *'
cpp(66) : error C2556: 'int weightLoss(double *)' : overloaded function differs only by return type from 'double weightLoss(double *)'
cpp(28) : see declaration of 'weightLoss'
cpp(66) : error C2371: 'weightLoss' : redefinition; different basic types
(74) : warning C4805: '!=' : unsafe mix of type 'double' and type 'bool' in operation