View Full Version: Military Time Converter

C++ Learning Community > C++ Works in Progress > Military Time Converter


Title: Military Time Converter
Description: A time converter...


shadow382 - October 29, 2005 05:44 AM (GMT)
Not sure if I should put this here or creations, but ohwell.

This is a military time converter. Enter a military time like 23 and it will tell you the am/pm time of that.

For the most part this is done, but I'm gonna add looping. Also I'm trying to find a way to make a am/pm to military time converter, but that's gonna be tough wil the am/pm difference. But I think I can do it.

Anyway here's the program. :D
CODE
///////////////////////////
/// Military Time Converter
/// Created by Shadow382
/// October 29, 2005
//////////////////////////

#include<iostream>
using namespace std;

 float militime, regtime;
 string answer;

int main()
{
 cout<<"***************************"<<endl;
 cout<<"* Military Time Converter *"<<endl;
 cout<<"***************************"<<endl;
 cout<<"       By Shadow382!\n"<<endl;
 cout<<"Enter time in military format: ";
 cin>>militime;
 if (militime > 12)
   {
     regtime=militime-12;
   }
 else
   {
     regtime=militime-0;
   }
 cout<<"\nThe am/pm time of "<<militime<<"00hrs is "<<regtime<<"";
 if (militime > 12)
   {
     cout<<"pm!\n"<<endl;
   }
 else
   {
     cout<<"am!\n"<<endl;
   }
 system("pause");
}


I'm gonna make a program with alot of mini-programs in it. This will be one of them, aswell as my calculator. Just gotta make enough before I can start of the main program. :P

Lemme know if anything needs to be fixed. ;)


-Shadow382

AquaFox - October 29, 2005 06:33 PM (GMT)
Everybody is into calculators these days O.o... Why not something else...?

xdracox - October 29, 2005 07:44 PM (GMT)
Because math with C++ is the first thing they teach you in C++ tutorials/books.

AquaFox - October 30, 2005 03:27 PM (GMT)
They would teach you math stuff like how to make S H I T go to reverse. Now THAT shows you grasped good math concepts. But CALCULATORS :s?

gnschmidt - November 2, 2005 12:42 PM (GMT)
I've never heard it called military time before - the 24h clock sounds friendlier...

raduking - November 2, 2005 05:18 PM (GMT)
QUOTE (gnschmidt @ Nov 2 2005, 12:42 PM)
I've never heard it called military time before - the 24h clock sounds friendlier...

me neither :)




Hosted for free by InvisionFree