Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
5
1.1 -1.3 4 -7.4 -3.6
... the program should output the following:
Negatives in reverse: -3.6 -7.4 -1.3However, the program doesn't work as it is intended to. Fix the bugs by annotating in the code directly. (Hint: There are 6 bugs). Note: Try to solve the problem by hand (and then double-check your answer by compiling and running your solution). |
|
|
|
hw.cpp that reads in information
about a series of flights and prints out information about the reverse journey.
After specifying how many legs are in the trip, the user will type in pairs of
airports like ABC->XYZ and the time that leg takes, either
formatted like 3:02, meaning 3 hours and 2 minutes. Each airport
will always be specified by a 3-letter code, separated with ->.
After reading in information on each leg of the journey, your program should
print out the reverse journey in one line with -> between the
airport names, and then the total time, formatted like 3 hours 2
minutes. You should be grammatically incorrect and always print
hours and minutes even if it's only one hour or
one minute.
If the airports do not match between two consecutive legs (specifically, if the
destination airport of one leg is different from the starting airport of the
next leg), your program should print out an error message "city
mismatch" and exit.
Example runs:
~/$ ./hw How many legs? 3 BWI->JFK 0:40 JFK->BUF 1:10 BUF->YYZ 0:30 Reverse trip: YYZ->BUF->JFK->BWI Total time: 2 hours 20 minutes | ~/$ ./hw How many legs? 1 DCA->DFW 2:03 Reverse trip: DFW->DCA Total time: 2 hours 3 minutes |
~/$ ./hw How many legs? 4 LHR->ORD 9:10 ORD->OGG 11:12 OGG->NRT 11:10 NRT->BNE 9:21 Reverse trip: BNE->NRT->OGG->ORD->LHR Total time: 40 hours 53 minutes | ~/$ ./hw How many legs? 10 DCA->EWR 0:58 LGA->YUL 1:26 city mismatch |
~/bin/submit -c=IC210 -p=hw21 hw.cpp