what`s wrong with it

C

CuTe_Engineer

hii,

can you tell me plzz why my programme doesn`t work ,i don`t have any
errors and every thing is fine but i don`t know why it`s not working ,
soo plz can you help me un finding my mistake
i will past the proramme here ,

the headers,

#include<string>

using namespace std;

#ifndef H_Gymnasium
#define H_Gymnasium



struct activities
{
string exercises;
int time;
};

class Gymnasium
{
protected:
activities gymarray[5];
int gymlength;
public:
void set(string,int);
void getActivities(string&,int&)const;
double calories();
void print();
Gymnasium(string="", int=0 );
};
#endif

#include<string>

using namespace std;

#ifndef H_Nutrition
#define H_Nutrition



struct meals
{
string food;
int portion;

};

class Nutrition
{
protected:
meals nutritionarray[5];
int nutritionLength;

public:
void set(string,int);
void getMeals(string& , int&)const;
void print();
Nutrition(string="" , int=0);
double calories();
};
#endif

#include <string>
#include"Regime.h"


#ifndef H_Patient
#define H_Patient

using namespace std;

struct person
{
string name;
double energy;
};

class Patient:public Gymnasium , public Nutrition,public Regime
{

public:
void set(string,int,string,int,string,double);
void get(string&,int& ,string& ,int&,string&,double&)const;
void print();
Patient(string= "",int=0,string="",int=0,string=0,double=0);
double calories(); // find the difference between gained & lost
calories and
//and sub. it from the energy
private:
person info;
Regime regimePlan;
};
#endif

#include<string>
#include"Gymnasium.h"
#include"Nutrition.h"

#ifndef H_Regime
#define H_Regime

using namespace std;

class Regime
{
public:
void set(string,int ,string,int);
void print();
Regime(string="" ,int=0,string="",int=0);
double calories();

private:
Gymnasium exercisePlan ;
Nutrition dietPlan;
};
#endif
===============================================
the implitation

#include <iostream>
#include <string>
#include "Gymnasium.h"

using namespace std;


const int gymlength=5;

void Gymnasium::set(string ex , int T )
{


gymarray[gymlength].exercises=ex;
gymarray[gymlength].time=T;



}

void Gymnasium::getActivities(string& ex , int& T )const
{


ex=gymarray[gymlength].exercises;
T=gymarray[gymlength].time;

}

void Gymnasium::print()
{
cout<<"He/She lost "<<calories()<<"calories"<<endl;
}

Gymnasium::Gymnasium(string ex , int T )
{

gymarray[gymlength].exercises=ex;
gymarray[gymlength].time=T;


}

double Gymnasium:: calories()
{
int total,calories ,i,lostcalories;

for(i=0;i>gymlength;i++)
{

if (gymarray.exercises=="OpenGym"){
calories=680*gymarray.time;

}
else if (gymarray.exercises=="Treadmill"){
calories=820*gymarray.time;

}
else if (gymarray.exercises=="Bike"){
calories=620*gymarray.time;

}
else if (gymarray.exercises=="Fitness"){
calories=740*gymarray.time;

}
else if (gymarray.exercises=="Hoop"){
calories=210*gymarray.time;
}
total+=calories;

}

lostcalories=total/60;
return lostcalories;

}

#include<iostream>
#include<string>
#include"Nutrition.h"

using namespace std;



const int Nutritionlength=4;

void Nutrition::set(string f , int p )
{
nutritionarray[Nutritionlength].food=f;
nutritionarray[Nutritionlength].portion=p;

}

void Nutrition ::getMeals(string&f , int&p )const
{
f=nutritionarray[Nutritionlength].food;
p=nutritionarray[Nutritionlength].portion;

}

Nutrition::Nutrition(string f , int p )
{
set(f,p);
}

double Nutrition::calories()
{
int total,calories ,i,gainedcalories;

for(i=0;i>4;i++)
{
nutritionarray.food;
nutritionarray.portion;

if (nutritionarray.food=="Carbohydrates"){
calories=90*nutritionarray.portion;

}
else if (nutritionarray.food=="Protein"){
calories=70*nutritionarray.portion;

}
else if (nutritionarray.food=="Vitamins"){
calories=50*nutritionarray.portion;

}
else if (nutritionarray.food=="Water"){
calories=10*nutritionarray.portion;

}

total+=calories;
}

gainedcalories=total/100;

return gainedcalories;
}
void Nutrition:: print()
{
cout<<"He/She gained "<<calories()<<"calories"<<endl;
}

#include<iostream>
#include <string>
#include"Patient.h"



using namespace std;

void Patient::set(string ex,int T,string f,int p,string n,double e)
{
Gymnasium::set(ex,T);
Nutrition::set(f,p);
info.name=n;
info.energy=e;

}

void Patient::get(string& ex,int& T ,string& f ,int& p,string&
n,double&e)const
{
Gymnasium::getActivities(ex,T);
Nutrition::getMeals(f,p);
n=info.name;
e=info.energy;
}

void Patient::print()
{

cout<<"Before the regime"<<info.name<<"energy was
"<<calories()<<"calories"<<endl;
Regime::print();
Gymnasium::print();
Nutrition::print();
}

Patient::patient(string ex,int T,string f,int p,string n,double
e):Gymnasium(ex,T),Nutrition(f,p),
Regime(ex,T,f,p)
{
n=info.name;
e=info.energy;
}

double Patient::calories()
{
int before;

before=Regime::calories()+600;

return before;
}

#include<iostream>
#include<string>
#include"Regime.h"


using namespace std;

void Regime::set(string ex,int T,string f,int p)
{
exercisePlan.set(ex,T);
dietPlan.set(f,p);
}

void Regime::print()
{
cout<<"After the regime Ahmed energy is
"<<calories()<<"calories"<<endl;
}

Regime::Regime(string ex,int T,string f,int p)
{
exercisePlan.set(ex,T);
dietPlan.set(f,p);
}

double Regime::calories()
{
int After;

After=dietPlan.calories()- exercisePlan.calories();

return After;
}
================================
the driver
#include<iostream>
#include<string>
#include<fstream>
#include"Gymnasium.h"
#include"Nutrition.h"
#include"Patient.h"
#include"Regime.h"

using namespace std;


int main()
{
Patient A;

int T,p ;
string f , ex , n;
double e;

cin>>n>>e;
cout<<endl;

ifstream inFile;

inFile.open("patientActivities.txt");

inFile>>ex>>T;


inFile.close();


inFile.open("patientMeals.txt");

inFile>>f>>p;

inFile.close();

A.set(ex,T,f,p,n,e);

A.print();

return 0;

}
 
R

red floyd

CuTe_Engineer said:
hii,

can you tell me plzz why my programme doesn`t work ,i don`t have any
errors and every thing is fine but i don`t know why it`s not working ,
soo plz can you help me un finding my mistake
i will past the proramme here ,

the headers,

[program redacted]

What's wrong with it? We're not psychic. Tell us what you were
expecting and what you got and why you think that's wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top