how do I create a program to change the time from numeric form to words.
here is an example
enter time: 7 23
out seven twenty three am
Can someone please give me some advice on how to make this program work? Here is my attempt so far
#include <iostream>
#include <string>
using namespace std;
int main ()
{
int t;
cout<<"Enter the time in numeric form"<<endl;
cin>> t;
if (t < 12)
{
cout << "AM" <<endl;
}
else (t >= 12);
cout << "PM" <<endl;
switch(t)
{
case 00:
cout<<" \n ";
break;
case 01:
cout<<" one ";
break;
case 02:
cout<<" two ";
break;
case 03:
cout<<" three ";
break;
case 04:
cout<<" four ";
break;
case 05:
cout<<" five ";
break;
case 06:
cout<<" six ";
break;
case 07:
cout<<" seven ";
break;
case 8:
cout<<" eight ";
break;
case 9:
cout<<" nine ";
break;
case 10:
cout<<" ten";
break;
case 11:
cout<<" eleven";
break;
case 12:
cout<<" twelve";
break;
case 13:
cout<<" thirteen";
break;
case 14:
cout<<" fourteen";
break;
case 15:
cout<<" fifteen";
break;
case 16:
cout<<" sixteen";
break;
case 17:
cout<<" seventeen";
break;
case 18:
cout<<" eightteen";
break;
case 19:
cout<<" nineteen";
break;
case 20:
cout<<" twenty";
break;
case 21:
cout<<" twenty one";
break;
case 22:
cout<<" twenty two";
break;
case 23:
cout<<" twenty three";
break;
case 24:
cout<<" twenty four";
break;
case 25:
cout<<" twenty five";
break;
case 26:
cout<<" twenty six";
break;
case 27:
cout<<" twenty seven";
break;
case 28:
cout<<" twenty eight";
break;
case 29:
cout<<" twenty nine";
break;
case 30:
cout<<" thirty";
break;
case 31:
cout<<" thrity one";
break;
case 32:
cout<<" thrity two";
break;
case 33:
cout<<" thrity three";
break;
case 34:
cout<<" thrity fout";
break;
case 35:
cout<<" thrity five";
break;
case 36:
cout<<" thrity six";
break;
case 37:
cout<<" thrity seven";
break;
case 38:
cout<<" thrity eight";
break;
case 39:
cout<<" thrity nine";
break;
case 40:
cout<<" forty";
break;
case 41:
cout<<" forty one";
break;
case 42:
cout<<" forty two";
break;
case 43:
cout<<" forty three";
break;
case 44:
cout<<" forty four";
break;
case 45:
cout<<" forty five";
break;
case 46:
cout<<" forty six";
break;
case 47:
cout<<" forty seven";
break;
case 48:
cout<<" forty eight";
break;
case 49:
cout<<" forty nine";
break;
case 50:
cout<<" fifty";
break;
case 51:
cout<<" fifty one";
break;
case 52:
cout<<" fifty two";
break;
case 53:
cout<<" fifty three";
break;
case 54:
cout<<" fifty four";
break;
case 55:
cout<<" fifty five";
break;
case 56:
cout<<" fifty six";
break;
case 57:
cout<<" fifty seven";
break;
case 58:
cout<<" fifty eight";
break;
case 59:
cout<<" fifty nine";
break;
}
return 0;
}
Last edited on