Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Two questions of C++. Use isostream, cmath, fstream, or the other things if you need. A certain airline is required to report statistics regarding their
Two questions of C++. Use isostream, cmath, fstream, or the other things if you need.
A certain airline is required to report statistics regarding their on-time flight performance. You've been given the following data sample consisting of the flight number, the scheduled arrival time, and the actual arrival time for a few flights. Scheduled Actual NW1735 NW1395 UA8863 NW2852 UA2740 NW1568 NW9886 DL2981 UA882 UA231 12:03 12:56 2:19 2:45 3:10 3:10 14:21 18:36 5:15 7:16 12:15 13:21 2:20 3:15 4:00 19:36 19:21 5:15 7:44 Write a C++program to record this data in a file. Specifically, write a program that will do the following: Open an output file with the filename flightData.dat and determine if the file was opened successfully. If not, provide a suitable error message and exit the program. Prompt the user and input three strings for the flight number and the two arrival times. Include the colon characterin the time values. Write the strings to the file. Each datum should be separated by a single space and the line should be delimited (terminated) with a newline n) Continue to input and write data to the file until the user inputs the sentinel string "end" (lowercase) for the flight number. Do not write the sentinel value to the file! Close the file before exiting the program. Example Enter the flight number: NW1735 Enter the scheduled/actual arrival times: 12:03 12:15 enter flight number NW1395 enter scheduled/actual arrival times: 12:56 13:21 enter flight number UA231 enter scheduled/actual arrival times: 7:16 7:44 enter flight number end Now test your program by entering all the flight data above. When you have finished entering the data, use a A certain airline is required to report statistics regarding their on-time flight performance. You've been given the following data sample consisting of the flight number, the scheduled arrival time, and the actual arrival time for a few flights. Scheduled Actual NW1735 NW1395 UA8863 NW2852 UA2740 NW1568 NW9886 DL2981 UA882 UA231 12:03 12:56 2:19 2:45 3:10 3:10 14:21 18:36 5:15 7:16 12:15 13:21 2:20 3:15 4:00 19:36 19:21 5:15 7:44 Write a C++program to record this data in a file. Specifically, write a program that will do the following: Open an output file with the filename flightData.dat and determine if the file was opened successfully. If not, provide a suitable error message and exit the program. Prompt the user and input three strings for the flight number and the two arrival times. Include the colon characterin the time values. Write the strings to the file. Each datum should be separated by a single space and the line should be delimited (terminated) with a newline n) Continue to input and write data to the file until the user inputs the sentinel string "end" (lowercase) for the flight number. Do not write the sentinel value to the file! Close the file before exiting the program. Example Enter the flight number: NW1735 Enter the scheduled/actual arrival times: 12:03 12:15 enter flight number NW1395 enter scheduled/actual arrival times: 12:56 13:21 enter flight number UA231 enter scheduled/actual arrival times: 7:16 7:44 enter flight number end Now test your program by entering all the flight data above. When you have finished entering the data, use aStep 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