d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With C++ > Bmi Question
Add Reply New Topic New Poll
Member
Posts: 17,865
Joined: Nov 8 2006
Gold: 44.00
Feb 26 2014 03:59pm
Ok so my program is supposed to be a like a clock, to show the time the person inputs and convert the time into a 12 hour clock

my problem is when I output 00 00 00

the first couple 00 shows 12 like its suposed to, but the other zeros dont show up, so im not getting a 12:00:00

can some1 help me with this

This post was edited by ZergBer on Feb 26 2014 03:59pm
Member
Posts: 1,241
Joined: Jun 25 2011
Gold: Locked
Feb 26 2014 04:23pm
Please post the relevant code
Member
Posts: 17,865
Joined: Nov 8 2006
Gold: 44.00
Feb 26 2014 06:40pm
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int HH, MM, SS;

cout << "Enter a time value in the following format: HH MM SS" << endl;
cout << setw(2) << setfill('0');
cin >> HH;

if (HH > 0 && HH <= 12)
{
cout << HH << ":";
}
else if (HH > 12 && HH < 24)
{
cout << HH - 12 << ":";
}
else if (HH == 0)
{
cout << HH + 12 << ":";
}
else
{
cout << "Hour must be between 0 and 23 inclusive.";
}

cout << setw(2) << setfill('0');
cin >> MM;

if (MM > 0)
{
cout << MM;
cout << ":";
}

cin >> SS;
cout << setw(2) << setfill('0');

if (SS > 0)
{
cout << SS;
}
if (HH >= 0 && HH < 12)
{
cout << "AM";
}
else if (HH >= 12 && HH < 24)
{
cout << "PM";
}

return 0;
}
Member
Posts: 17,865
Joined: Nov 8 2006
Gold: 44.00
Feb 26 2014 07:33pm
nvm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 26 2014 07:47pm
Quote (ZergBer @ Feb 26 2014 08:33pm)
nvm


i assumed you figured it out. but what does this have to do with BMI? i assumed it stood for body-mass-index, but that doesnt seem so likely
Member
Posts: 17,865
Joined: Nov 8 2006
Gold: 44.00
Feb 26 2014 09:17pm
Quote (carteblanche @ Feb 27 2014 01:47am)
i assumed you figured it out. but what does this have to do with BMI? i assumed it stood for body-mass-index, but that doesnt seem so likely


Yeah sorry my bad, I put the wrong question for a diff problem XD

but yeah I figured it out
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll