Hey all! Need help with some homework... basically i had to build a program where you input your name, weight, and minutes for four activities ... i then had it calculate calories burned as well. on my program it brings up <iomanip> chart for each category... i need to get the time spent category to show hours:minutes and not just the minutes... this is what i have so far... everything is good but when i run it... the time is still in minutes for each individual event
// <Steven Kidwell>
// Sample program to show calories burned and time in each event
// CSCI 1010 Programming Assignment 3
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int w;
int bm;
int rm;
int wm;
int wlm;
int bh;
int rh;
int wh;
int wlh;
double bc;
double rc;
double wc;
double wlc;
int hours;
int minutes;
double cals;
double const badrate = .044;
double const runrate = .087;
double const walkrate = .036;
double const wlrate = .042;
char fname[10], lname[15];
// Input all data and information
cout << "Please enter your first and last name: ";
cin >> fname >> lname;
cout << "Please enter your weight: ";
cin >> w;
cout << "Please enter the minutes spent playing badminton: ";
cin >> bm;
cout << "Please enter the minutes spent running: ";
cin >> rm;
cout << "Please enter the minutes spent walking: ";
cin >> wm;
cout << "Please enter the minutes spent lifting weights: ";
cin >> wlm;
cout << endl;
cout << "Here are the results for: ";
cout << fname << " " << lname << endl;
cout << endl;
//Calculations for minutes per event
bc = w * badrate * bm;
rc = w * runrate * rm;
wc = w * walkrate * wm;
wlc = w * wlrate * wlm;
//Calculations for time spent in hours/minutes and calories burned
hours = (bm + rm + wm + wlm) / 60;
minutes = (bm + rm + wm + wlm) % 60;
cals = bc + rc + wc + wlc;
I suggest to add function to display time to simplify code.
You can contact us live at http://www.assignments.me/cpp.html for help with assignment. starting from $10