Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP ME IMPROVE WTIH THIS CODE IN C + + PROGRAMMING C + + CODE: #include #include using namespace std; int computeDifference ( int
PLEASE HELP ME IMPROVE WTIH THIS CODE IN C PROGRAMMING
C CODE:
#include
#include
using namespace std;
int computeDifferenceint startHour, int startMin, bool isStartAM, int futureHour, int futureMin, bool isFutureAM
Convert start and future times to hour format
if isStartAM && startHour
startHour ;
if isFutureAM && futureHour
futureHour ;
if isStartAM && startHour
startHour ;
if isFutureAM && futureHour
futureHour ;
Calculate time difference in minutes
int startTotalMin startHour startMin;
int futureTotalMin futureHour futureMin;
int difference futureTotalMin startTotalMin;
if difference
difference ;
return difference;
int main
Get user input for start time
int startHour, startMin, futureHour, futureMin;
char startPeriod, futurePeriod;
cout "Enter start time in format HH:MM AMPM: ;
cin startHour;
cin.ignore:; Ignore colon delimiter
cin startMin startPeriod;
bool isStartAM startPeriod A startPeriod a;
Get user input for future time
cout "Enter future time in format HH:MM AMPM: ;
cin futureHour;
cin.ignore:; Ignore colon delimiter
cin futureMin futurePeriod;
bool isFutureAM futurePeriod A futurePeriod a;
Compute time difference and display result
int difference computeDifferencestartHour startMin, isStartAM, futureHour, futureMin, isFutureAM;
cout "Time difference in minutes: difference endl;
return ;
Additional intructions:
Modify the time machine application to go back and forth Multiple times
by entering the time desired minutes. It could be that the user can move
forward further or go back
For example :
Present and Future time are fixed and minutes difference are to be computed
Initial time : : AM
Second time : :
Third to succeeding iteration can be achieved by deducting or adding intervals
per minutes
Third time : : AM
Fourth time : : AM
Initial time :
Future time :
Minutes Difference:
Would you like to travel more
Yes...
Enter Minutes :
You are now in:
Would you like to travel more
Yes...
Enter Minutes :
You are now in:
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