1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
#include <iostream>
#include <cctype>
using namespace std;
bool input(double current_weight, double height, double desired_weight, int age, int days, bool &gender);
void male_calculation (double current_weight, double height, double desired_weight, int age, int days);
void female_calculation (double current_weight, double height, double desired_weight, int age, int days);
void function_call ();
int main()
{
int current_weight = 0, height = 0, desired_weight = 0, age = 0, days = 0;
bool gender;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
input (current_weight, height, desired_weight, age, days, gender);
if (gender = true)
male_calculation (current_weight, height, desired_weight, age, days);
else
female_calculation (current_weight, height, desired_weight, age, days);
return 0;
}
bool input (double current_weight, double height, double desired_weight, int age, int days, bool& gender)
{
cout << "This program will calculate the amount of excercises and the total calories\n"
"That you need a day to acquire your desired weight.\n"
"Enter your current weight\n";
cin >> current_weight;
cout << "Your height in inches?\n";
cin >> height;
cout << "Your desired weight?\n";
cin >> desired_weight;
cout << "Your age in year?\n";
cin >> age;
cout << "In how long do you want to reach your desired weight?\n"
"Please enter the days.\n";
cin >> days;
cout << "Press M if you are male and F for female.\n";
cin >> gender;
gender = toupper(gender);
if (gender = 'M')
gender = true;
else if (gender = 'F')
gender = false;
}
void male_calculation (double current_weight, double height, double desired_weight, int age, int days)
{
double weight_in_kilogram, height_in_cm, weight_difference, calories_to_lose, calories_to_gain_or_lose, men_bmr;
double number_of_fast_food_meals, number_of_healthy_meals, calories_per_day, ounce_of_steak, total_calories;
weight_in_kilogram = current_weight/2.2;
height_in_cm = height*2.54;
weight_difference = desired_weight - current_weight;
men_bmr = 88.362 + (13.397*weight_in_kilogram) + (4.799*height_in_cm) - (5.677*age);
calories_to_gain_or_lose = weight_difference*3500;
calories_per_day = calories_to_gain_or_lose/days;
number_of_fast_food_meals = calories_per_day/1655;
number_of_healthy_meals = calories_per_day/665;
ounce_of_steak = number_of_healthy_meals*8;
if (weight_difference > 0)
{
cout << "In order to maintain your current weight, you will need " << men_bmr << " calories a day.\n";
cout << "To be " << desired_weight << "lbs in " << days << " days, you will need to consume\n"
<< calories_per_day << " calories a day on top of " << men_bmr << " calories needed to maintain your weight.\n"
"This is equivalent to " << number_of_fast_food_meals << " double double, " << number_of_fast_food_meals << " fries and " << number_of_fast_food_meals << " chocolate shake that you will need to eat a day from in and out.\n"
"However, if you are a healthy eater, you may choose to eat " << ounce_of_steak << " Oz of sirloin steak and \n"
<< number_of_healthy_meals << " cup of broccoli and pasta a day.\n";
}
double minutes_to_run, minutes_to_walk, minutes_of_basketball;
minutes_to_run = calories_per_day/(0.0385*17*current_weight);
minutes_to_walk = calories_per_day/(0.0385*current_weight);
minutes_of_basketball = calories_per_day/(0.0385*8*current_weight);
cout << weight_difference;
if (weight_difference < 0)
{
cout << "In order to lost " << weight_difference << "lbs in " << days <<" days, you will need one of the following activities if you consume " << men_bmr << " calories a day.\n"
<< minutes_to_walk << " minutes of walking or\n"
<< minutes_of_basketball << " minutes of playing basketball or\n"
<< minutes_to_run << " minutes of running a day.\n";
}
}
void female_calculation (double current_weight, double height, double desired_weight, int age, int days)
{
double weight_in_kilogram, height_in_cm, weight_difference, calories_to_lose, calories_to_gain_or_lose, women_bmr;
double number_of_fast_food_meals, number_of_healthy_meals, calories_per_day, ounce_of_steak, total_calories;
weight_in_kilogram = current_weight/2.2;
height_in_cm = height*2.54;
weight_difference = desired_weight - current_weight;
women_bmr = 447.593 + (9.247*weight_in_kilogram) + (3.098*height_in_cm) - (4.33*age);
calories_to_gain_or_lose = weight_difference*3500;
calories_per_day = calories_to_gain_or_lose/days;
number_of_fast_food_meals = calories_per_day/1655;
number_of_healthy_meals = calories_per_day/665;
ounce_of_steak = number_of_healthy_meals*8;
if (weight_difference > 0)
{
cout << "In order to maintain your current weight, you will need " << women_bmr << " calories a day.\n";
cout << "To be " << desired_weight << "lbs in " << days << " days, you will need to consume\n"
<< calories_per_day << " calories a day on top of " << women_bmr << " calories needed to maintain your weight.\n"
"This is equivalent to " << number_of_fast_food_meals << " double double, " << number_of_fast_food_meals << " fries and " << number_of_fast_food_meals << " chocolate shake that you will need to eat a day from in and out.\n"
"However, if you are a healthy eater, you may choose to eat " << ounce_of_steak << " Oz of sirloin steak and \n"
<< number_of_healthy_meals << " cup of broccoli and pasta a day.\n";
}
double minutes_to_run, minutes_to_walk, minutes_of_basketball;
minutes_to_run = calories_per_day/(0.0385*17*current_weight);
minutes_to_walk = calories_per_day/(0.0385*current_weight);
minutes_of_basketball = calories_per_day/(0.0385*8*current_weight);
if (weight_difference < 0)
{
cout << "In order to lost " << weight_difference << "lbs in " << days <<" days, you will need one of the following activities if you consume " << women_bmr << " calories a day.\n"
<< minutes_to_walk << " minutes of walking or\n"
<< minutes_of_basketball << " minutes of playing basketball or\n"
<< minutes_to_run << " minutes of running a day.\n";
}
}
|