Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I know my switch is wrong but I can't figure out what I ' m supposed to use. Please check the rest of the code
I know my switch is wrong but I can't figure out what Im supposed to use. Please check the rest of the code as well and see if I messed anything up or if you have any suggestions. I haven't been able to run the debugger yet so Im not sure if Im totally off on other things. Thank you!
#include
#include
#include
#include
using namespace std;
This program will add one to each unit of time
chosen by the user. Use a menu to pick the unit of time.
Print out the clock in two formats, and hour.
Author: Jordan Alarie
Date:
Global variables
int hours;
int minutes;
int seconds;
Gets the current time from the mother board
Assigns it to hours, minutes, and seconds variables
void GetTime
timet ttime time; Set ttime as argument for localtime function
tm localtime localtime&ttime; Holds the local time
Assigns hours, minutes, and seconds from the localtime variable
hours localtimetmhour;
minutes localtimetmmin;
seconds localtimetmsec;
Prints menu and asks for user choice
Returns user choice
int menu
int choice;
Display menu
cout "Please make a section from the menu below." endl;
cout string endl;
cout Add One Hour tt endl;
cout Add One Minute tt endl;
cout Add One Second tt endl;
cout Exit ttt endl;
cout string endl;
Get input
cin choice;
cout "You selected: choice endl;
Adds one unit to the hours
Returns the updated time
void addHour
hours hours ;
Adds one unit to the minutes
Returns the updated time
void addMinute
minutes minutes ;
if minutes
addHour;
Adds one unit to the seconds
Returns the updated time
void addSecond
seconds seconds ;
if seconds
addMinute;
Prints the hour clock
Parameter:hour min and sec
Returns nothing
void printint hours, int minutes, int seconds
cout setw setfill hours :
setw setfill minutes :
setw setfill seconds;
Prints the hour clock
Parameter:hour min and sec
Returns nothing
void printint hours, int minutes, int seconds
cout setw setfill hours :
setw setfill minutes :
setw setfill seconds;
if hours
cout AM;
else
cout PM;
int main
int choice;
bool exitFlag false;
while exitFlag
Gets the time from the motherboard
GetTime;
Displays menu and takes choice
menu;
Uses selection to add to requested time
switch choice
case :
printaddHour;
printaddHour;
case :
printaddMinute;
printaddMinute;
case :
printaddSecond;
printaddSecond;
case :
exitFlag true;
break;
Print clocks
print;
print;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started