Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Lab 5- Reading and Writing Files Objectives Read and write to and from data files. Make use of Sentinel values, while reading data Understand
C++
Lab 5- Reading and Writing Files Objectives Read and write to and from data files. Make use of Sentinel values, while reading data Understand the usefulness of .eof0 method Setup: Create a data file of the following integers: 10 20 30 17 21 18 30 20 49 40 25 35 55 45 35 25 55 5 Make sure to leave a blank line at the end of the file. Right click on Source Folder, add, new item, Click on Utility on the side of the panel. Then select text file, make sure to give it a name. If you want to name is input.txt, please just type input, Visual Studio will automatically add the txt. If you name it input.txt, the file will actually be called input.txt.txt (Do not double click on it until you name it.) In C++, you just have to copy and paste the text data file into the same folder that the program is in and name it something like "input". The xt will automatically be placed after the name Create an input file (see above). The output file will be created when the program runs. Read in the data, three (3) values at a time, from the input file. You will continue to do this until you read the sentinel data line (1,-1.-1). Arrange the three values that have been read in order from lowest to highest, and then write the set of three numbers to the output file in this ascending order. Use a series of if statements to find the smallest, the middle, and the largest value. When all lines of data have been processed, close both files. Then reopen the output file as input. (fin.open("output.txt"):) Read the data back into your program and print it to the screen. Make sure to use while not End of File to determine when you are done reading data from the file (instead of the sentinel value you used above.) The Sentinel Values (1,-1,-1) should NOT appear in your output file. Run: Run the program as normal; verify that the results on the screen are correct. You should NOT see -1-1-1 in either your output file or on the screen Submission: You will need to turn in four (4) documents. Turn in a copy of the source file (.cpp file), the input file (so I can run your programs), and the two output files - the one on the disk which does not have Coded by " statement and the output on the screen which does have the "Coded by.." statement on it. Please submit all four files in a zipped folder into the D2L 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