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
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int inputNumber(string);
int calculateCalories_Hours(int);
int calculateCalories_Mins(int);
double calculateCalories(double, int, int);
void displayHeadings();
void displayLine(int, int, double);
int main()
{
string name;
int user_Weight,
weight,
badminton_Mins_User,
running_Mins_User,
walking_Mins_User,
weight_Training_Mins_User,
badminton_Hours_Amount,
running_Hours_Amount,
walking_Hours_Amount,
weight_Training_Hours_Amount,
badminton_Mins_Amount,
running_Mins_Amount,
walking_Mins_Amount,
weight_Training_Mins_Amount,
total_Time,
total_Hours,
total_Mins;
double badminton_Cals_Amount,
running_Cals_Amount,
walking_Cals_Amount,
weight_Training_Cals_Amount,
total_Cals_Burned;
const double BADMINTON_BURN_RATE_PLB = 0.044,
RUNNING_BURN_RATE_PLB = 0.087,
WALKING_BURN_RATE_PLB = 0.036,
WEIGHT_TRAINING_BURN_RATE_PLB = 0.042;
cout << "Welcome to the Workout calculator." << endl;
cout << "User, please enter your name: " << endl;
getline(cin, name);
weight = inputNumber( "Please enter your weight:");
badminton_Mins_User = inputNumber("Please enter the minutes spent playing badminton: ");
running_Mins_User = inputNumber("Please enter enter the minutes spent Running: ");
walking_Mins_User = inputNumber("Please enter enter the minutes spent Walking: ");
weight_Training_Mins_User = inputNumber("Please enter enter the minutes spent Weight-training: ");
cout << "Here are the results for " << name << endl;
displayHeadings();
// badminton function calls
badminton_Hours_Amount = calculateCalories_Hours(badminton_Mins_User);
badminton_Mins_Amount = calculateCalories_Mins(badminton_Mins_User);
badminton_Cals_Amount = calculateCalories(BADMINTON_BURN_RATE_PLB, weight, badminton_Mins_User);
//running function calls
running_Hours_Amount = calculateCalories_Hours(running_Mins_User);
running_Mins_Amount = calculateCalories_Mins(running_Mins_User);
running_Cals_Amount = calculateCalories(RUNNING_BURN_RATE_PLB, weight, running_Mins_User);
//walking function calls
walking_Hours_Amount = calculateCalories_Hours(walking_Mins_User);
walking_Mins_Amount = calculateCalories_Mins(walking_Mins_User);
walking_Cals_Amount = calculateCalories(WALKING_BURN_RATE_PLB, weight, walking_Mins_User);
//weight training function calls.
weight_Training_Hours_Amount = calculateCalories_Hours(weight_Training_Mins_User);
weight_Training_Mins_Amount = calculateCalories_Mins(weight_Training_Mins_User);
weight_Training_Cals_Amount = calculateCalories(WEIGHT_TRAINING_BURN_RATE_PLB, weight, weight_Training_Mins_User);
total_Time = badminton_Mins_User + running_Mins_User + walking_Mins_User + weight_Training_Mins_User;
total_Cals_Burned = badminton_Cals_Amount + running_Cals_Amount + walking_Cals_Amount + weight_Training_Cals_Amount;
total_Hours = total_Time / 60;
total_Mins = total_Time % 60;
void displayLine(int badminton_Hours_Amount, int badminton_Mins_Amount, double badminton_Cals_Amount, int running_Hours_Amount, int running_Mins_Amount,
double running_Cals_Amount, int walking_Hours_Amount, int walking_Mins_Amount, double walking_Cals_Amount, int weight_Training_Hours_Amount, int weight_Training_Mins_Amount,
double weight_Training_Cals_Amount, double total_Cals_Burned, int total_Hours, int total_Mins);
system("PAUSE");
return 0;
}
int inputNumber(string prompt )// Takes the input from the user.
{
int inputtedValue = 0; // declare a variable to hold a value
cout << prompt; // output the prompt
cin >> inputtedValue; // collect a number from the user
return inputtedValue; // return the value inputted
}
int calculateCalories_Hours(int a) //calculates the hours.
{
return(a/60);
}
int calculateCalories_Mins(int a) //calculates the minutes.
{
return (a&60);
}
double calculateCalories(double cons_Burn_Rate, int weight_User, int mins_User)
{
return (cons_Burn_Rate*weight_User*mins_User);
}
void displayHeadings()
{
cout << "\nActivity" << setw(16) << "Time" << " " << "Calories\n";
//The setw puts in how many spaces between activity and Time.
cout << "----------------------------------\n" << endl;
}
void displayLine()
{
int mins_Excercise_Mins = 0,
hours_Exercise_Totals =0,
total_Hours = 0,
total_Minutes = 0 ;
double Cals_Burned =0 ,
total_Cals_Burned = 0;
cout << setprecision(3) << fixed;
cout << "Badminton" << setw(12) << hours_Exercise_Totals << ":" << setfill('0') << setw(2) << mins_Excercise_Mins
<< setfill(' ') << " " << setw(7) << Cals_Burned << endl;
cout << "Running" << setw(14) << hours_Exercise_Totals << ":" << setfill('0') << setw(2) << mins_Excercise_Mins
<< setfill(' ') << " " << setw(7) << Cals_Burned << endl;
cout << "Walking" << setw(14) << hours_Exercise_Totals << ":" << setfill('0') << setw(2) << mins_Excercise_Mins
<< setfill(' ') << " " << setw(7) << Cals_Burned << endl;
cout << "Weights" << setw(14) << hours_Exercise_Totals << ":" << setfill('0') << setw(2) << mins_Excercise_Mins
<< setfill(' ') << " " << setw(7) << Cals_Burned << endl;
cout << "----------------------------------\n";
cout << "Totals" << setw(15) << total_Hours << ":" << setfill('0') << setw(2) << total_Minutes
<< setfill(' ') << " " << setw(7) << total_Cals_Burned << endl;
}
|