Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CS 240 Fall 2017 Program #2 100 Points Deadline: Friday, October 6 11:55PM You a

ID: 3587344 • Letter: C

Question

CS 240 Fall 2017 Program #2 100 Points Deadline: Friday, October 6 11:55PM You are to create a class called FitnessTracker that tracks calories and weight for a person over the course of some days. This class must store the following data about a person: Age (in whole years) Height (in inches) Weight (in pounds) Gender 'M'or 'F' Calories Burned Calories Consumed Create the following functions in the class: Default and initializing constructors. Accessor (set) functions. Mutator (get) functions. Functions that calculate the Resting Metabolic Rate (RMR), and the difference between calories burned and calories Functions to add calories burned and calories consumed. . An adjust weight function that calculates the person's change in weight and applies the change to the person's weight (return the amount of weight change). An overloaded output operator that shows all the data members plus the RMR and difference in calories. Overloaded Boolean comparison operators that compare based on the RMR of two FitnessTrackers. Make sure to convert both RMR values to ints so the will work more effectively. You won't need these in the driver, but you must have them Formulas for calculating the RMR and weight change are as follows: RMR: Males: 66 +(6.22 x weight (Ibs) +(12.7x height (inches)) (6.8 x age) Females: 655 (4.36 x weight (lbs))+(4.32 x height (inches) - (4.7 x age) Weight change difference in calories)/3500.0 Driver Details: Print a welcoming message at the start of the program. Have the user enter a person's age, height, weight, and gender. Calculate the person's RMR right away and add it to their calories burned. Then show the

Explanation / Answer

#include <iostream>

using namespace std;

class FitnessTracker

{

int age;

double height;

double weight;

char gender;

double caloriesBurned;

double caloriesConsumed;

  

public:

  

FitnessTracker()

{

age = 0;

height = 0;

weight = 0;

gender = 'M';

caloriesBurned = 0;

caloriesConsumed = 0;

}

  

FitnessTracker(int a, double h, double w, char g, double cb, double cc)

{

age = a;

height = h;

weight = w;

gender = g;

caloriesBurned = cb;

caloriesConsumed = cc;

}

  

void setAge(int a)

{

age = a;

}

void setHeight(double h)

{

height = h;

}

void setWeight(double w)

{

weight = w;

}

void setGender(char g)

{

gender = g;

}

void setCaloriesBurned(double cb)

{

caloriesBurned = cb;

}

void setCaloriesConsumed(double cc)

{

caloriesConsumed = cc;

}

int getAge()

{

return age;

}

double getHeight()

{

return height;

}

double getWeight()

{

return weight;

}

char getGender()

{

return gender;

}

double getCaloriesBurned()

{

return caloriesBurned;

}

double getcaloriesConsumed()

{

return caloriesConsumed;

}

  

double calculateRMR()

{

double rmr;

if(gender == 'M')

{

rmr = 66 + (6.22 * weight) + (12.7 * height) - (6.8 * age);

}

else

{

rmr = 655 + (4.36 * weight) + (4.32 * height) - (4.7 * age);

}

return rmr;

}

  

double calDiff()

{

return caloriesBurned - caloriesConsumed;

}

  

double calBurnAdd(double cal)

{

return caloriesBurned + cal;

}

  

double calConAdd(double cal)

{

return caloriesConsumed + cal;

}

  

double adjustWeight()

{

double change;

change = calDiff()/3500;

weight = weight - change;

return change;

}

  

friend ostream &operator<<( ostream &output, FitnessTracker &D )

{

output << " Age: " << D.getAge() << " Height: " << D.getHeight()<< " Weight: " << D.getWeight();

output << " Gender: " << D.getGender() << " Calories Burned: " << D.getCaloriesBurned() << " Calories Gained: " << D.getcaloriesConsumed();

output << " RMR: " << D.calculateRMR()<< " Difference in Calories: " << D.calDiff();

return output;   

}

  

bool operator==(FitnessTracker &D)

{

int rmrFirst, rmrSecond;

rmrFirst = this->calculateRMR();

rmrSecond = D.calculateRMR();

  

if(rmrFirst == rmrSecond)

return true;

else

return false;

}

  

};

int main() {

int age, choice=0;

double height, weight, cb, cc, rmr;

char gender;

cout<<" Welcome to Finess Tracker Please enter following info";

cout<<" Age: ";

cin>>age;

cout<<" Height: ";

cin>>height;

cout<<" Weight: ";

cin>>weight;

cout<<" Gender: ";

cin>>gender;

FitnessTracker ft(age, height, weight, gender, 0, 0);

rmr = ft.calculateRMR();

ft.setCaloriesBurned(ft.getCaloriesBurned() + rmr);

cout<<" Your Fitness Data is:";

cout<<ft;

while(choice!=4)

{

cout<<" Menue";

cout<<" 1.Add Calories 2.Do some exercise 3. End Day 4.Quit";

cin>>choice;

switch(choice)

{

case 1: cout<<" Enter the amount of calories consumed: ";

cin>>cb;

ft.calConAdd(cb);

break;

case 2: // Call the functions you need according to the chart given.

break;

case 3: ft.adjustWeight();

cout<<" Weight changed: "<<ft.calDiff();

rmr = ft.calculateRMR();

ft.setCaloriesBurned(ft.getCaloriesBurned() + rmr);

ft.setCaloriesConsumed(0);

break;

case 4: break;

}   

}

}

-------------------------------------------------------------------------------------------------------------------

I have written all the program as mentioned in the question. The name of the functions explain what their purpose is . You just have to write the Do some exercise part of the main function by calling specific functions based on the given chart.