Question: I need help getting my program to work. Please help. Thanks. /****************************************************************************** CS265 Programming in C++ Week 5 Assignment Make a program to convert the
I need help getting my program to work. Please help. Thanks.
/******************************************************************************
CS265 Programming in C++
Week 5 Assignment
Make a program to convert the time from 24-hour notation to 12-hour notation
and vice versa. Your program must be menu driven, giving the user the choice of
converting the time between the two notations. Furthermore, your program must
contain at least the following functions: a function to convert the time from
24-hour notation to 12-hour notation, a function to convert the time from 12-hour
notation to 24-hour notation, a function to display the choices, function(s) to
get the input, and function(s) to display the results. (For 12-hour time notation,
your program must display AM or PM).
*******************************************************************************/
#include
#include
using namespace std;
int choice;
int timeofday;
int hour;
int minute;
void showChoices();
void input (int c);
void twelvetotwentyfour(int h, int m, int t);
void twentyfourtotwelve(int h, int m, int t);
void showtime12 (int h, int m, int t);
void showtime24 (int h, int m, int t);
int main()
{
cout
cout
cout
do
{
showChoices ();
input;
cout
switch (choice)
{
case 1:
cout
cout
cin >> hour;
cout
cin >> minute;
cout
cin >> timeofday;
twelvetotwentyfour (hour, minute, timeofday);
showtime24 (hour, minute, timeofday);
break;
case 2:
cout
cout
cin >> hour;
cout
cin >> minute;
twentyfourtotwelve (hour, minute, timeofday);
showtime12 (hour, minute, timeofday);
break;
case 9:
break;
default:
cout
}
}
while (choice != 9);
return 0;
}
void showChoices()
{
cout
cout
cout
cout
}
void input (int c)
{
c= choice;
cin >> choice;
}
void twelvetotwentyfour (int h, int m, int t)
{
h = hour;
m = minute;
t = timeofday;
if (timeofday == 0)// 0 = AM
{
h = hour - 12;
}
else h = 12 + hour;
}
void twentyfourtotwelve (int h, int m, int t)
{
h = hour;
m = minute;
t = timeofday;
if (hour > 12)
{
h = hour - 12;
}
else hour = hour;
{
}
}
void showtime12 (int h, int m, int t)
{
h = hour;
m = minute;
t = timeofday;
cout
cout
cout
}
void showtime24 (int h, int m, int t)
{
h = hour;
m = minute;
t = timeofday;
cout
cout
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
