Question: your time machine is capable of going forward in time up to 24 hours. the machine is configured to jump ahead in minutes. to enter

your time machine is capable of going forward in time up to 24 hours. the machine is configured to jump ahead in minutes. to enter the proper number of minutes into your machine, you would like a program that can take a start time ( in hours minutes and a Boolean indicating AM or PM) and a future time indicating ( in hours , minutes and a Boolean indicating AM or PM) and calculate the difference in minutes between the start and future time.

A time is specified in your program with three variables. -int hours, minutes -bool is am for example to represent 11:50 p.m. you should store hours = 11, minutes = 50, isAM =false this means that you need 6 variables to store a start and future time. write a program that allows the user to enter start time and future time include a function named computeDifference that takes the six variables as parameters that represent the start time and future time your function should return as an instant the time difference in minutes for example given a start time of 11:59 a.m. and a future time of 12:01 p.

your time machine is capable of going forward in time up to

m. your program should compute 2 minutes as time difference given a start timeof 11:59 a.m. and a future time of 11:58 a.m. your program should compute 1439 minutes as the time difference (23 hours and 59 minutes). You may need "AM" or "PM" from the users in put by reading in two character variables. characters can be compared just like numbers.

24 hours. the machine is configured to jump ahead in minutes. to

***The white screen print is my code, however, I have a logic issue and can't find it. please help. I need my window to look EXACTLY LIKE THE BLACK SCREEN PRINT.

enter the proper number of minutes into your machine, you would like

Here is my code :

#include using namespace std;

int computeDifference(int startHr, int startMin, int endMin, int endHr, bool isAM1, bool isAM2);// Function Declaration: These are the six parameters to

int main() { int starthour, startminute, endminute, endhour, minutes, hours; bool isAM1 = false, isAM2 = false; char AM1, PM1, AM2, PM2, colon, answer;

//I'm using the do-while loop to be able to repeat the loop with a yes or no answer from the user do { cout > starthour >> colon >> startminute >> AM1 >> PM1; // It takes the entry from the user to be able to put as integers and chars

cout > endhour >> colon >> endminute >> AM2 >> PM2;

if ((AM1 == 'a') || (AM1 == 'A'))// For the boolean expression. If an 'a' is stated that the statement is true. isAM1 = true; if ((AM2 == 'a') || (AM2 == 'A'))// Same as above... I realized here I should of renamed AM a little bit differently. isAM2 = true;

minutes = computeDifference(starthour, startminute, endminute, endhour, isAM1, isAM2) % 60; // Percent sign shows the remainder hours = computeDifference(starthour, startminute, endminute, endhour, isAM1, isAM2) / 60;// Conversion

cout

cout > answer; if (answer == 'y' || answer == 'Y') //Allows the user to repeat or stop the program { isAM1 = false; //current time both PM isAM2 = false; //future time }

} while ((answer == 'y' || (answer == 'Y')));

return 0;

}

int computeDifference(int startHr, int startMin, int endMin, int endHr, bool isAM1, bool isAM2)//Remember the order is important later on { int difference = 0; // local variable because main doesnt use it if ((isAM1 == true) && (isAM2 == false))// going to AM to pm { if (startHr == 12) // therefore am { startHr = 0; } difference = (((endHr - startHr) * 60) - (startMin - endMin)); }

if ((isAM1 == false) && (isAM2 == true)) // Going to PM to AM { if (endHr == 12) // therefore am { endHr = 24*60; }

if (startHr

difference = (endHr - startHr) + (endMin - startMin); }

return difference ;//The function is called to be able to return this to make the main function as small as possible. It helps the programmer to fix problems easier.

ile Edn Format View Helgp int conputedtfferencetint startar, int startnin, int endvin, int enar, bool isu, bool 35s82) runction Declarations These are the stx persmeters to int nain() int starthour, startminute, endsisute, endhour, ninutes, hours I ISAy 1. false, isau . false i har Arl, 1, 2, colon, answer; //I'a using the do-h1le loop to be able to repest the loop with a yes or no answer fros the user cout > start 'here ,xx' is seither 'a' or 'pr far , or mi- ters and chers tout .inEmter future tise in the formet ..n' 'tere-xe' isire i ter -an' or, tn't r 7 For the boolesn expression. if an a is statea that tne staterent is true, ((AMI > 11 CAMI a. .A"))// For the booleen expression, 2f an " SAN3true ane es abowe., I reaiised here i should or rectie bit detterently f I realized h {(Art24.awy.ile(Awa-- SAPZtrue "A)/ ian)-://pencerts minutes . co"puteDifference(starthour, stertelnute, ondninute, endteur, hours - computeD1fference(sterthour, startminute, endnirute, enaho suu, Thours and mike minutes covt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!