I am new to this forum. I am searching for some help for my girlfriend and I. My girlfriend is taking a course in computer science and for her homework she is stuck on the final question.
You're very unlikely to get code written for you here. The best thing to do is to either paste the code you have now to show you made an attempt, or to atleast attempt it and then ask for which parts you're getting stuck on.
I understand. I know it is bad to ask that. It is just that there is no way she can figure this out and I want us to look at it and figure it out. Reverse Engineering heh.
} else { // the second plane came before the first plane
return ((h1 + 1440) - h2); // Should be (h2 + 1440) - h1)
}
The reasoning behind this is because the second plane would have an earlier time than the first plane. How you have it now is that not only is the first plane's converted time larger as is, but you just added another 24 hours to it to make it even larger.
Edit: I see another spot. Here:
1 2 3 4 5 6
void display(string msg, int mins) {
cout << msg;
int hours = mins / 60;
int mins = mins % 60;
cout << msg << hours << " hr " << mins << " min" << endl;
}
You already passed the variable mins, you can't redeclare the variable within the function. You also printed out the msg twice.
1 2 3 4 5
void display(string msg, int mins) {
int hours = mins / 60;
mins = mins % 60;
cout << msg << hours << " hr " << mins << " min" << endl;
}
That should fix it.
cin >> secondMin is incorrect.
int main(int argc) if you aren't going to use argc just use int main()
display("Total Trip: ", (firstHour * 60) + firstMin + layover); This math is wrong.
That should give you everything that you need to run your program and error test it.