Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 02: SEQUENTIAL ACCESS FILES Write the statement you are asked to write in ea

ID: 3539653 • Letter: L

Question

Lab 02: SEQUENTIAL ACCESS FILES

Write the statement you are asked to write in each part. You do not need to write a complete program.

PROBLEM 3

We want to use a C++ program to create a sequential access file. The data we want to store in the file are the number of cars the appraisers of an insurance company processed in the past 3 weeks. Each row in the file is the data for one appraiser. The first, second, and third number in each row is the number of cars processed in the first, second and third week, respectively. For example, the first row of the file is shown below:

20 23 19

Instead of writing a complete program, please write the following statements:

(a) Write a statement to create an ofstream named carsData.

(b) Write a statement to assign the sequential access file "cars.txt" to the ofstream carsData. Open it for writing with the ios::out option.

(c) Suppose we have the number of cars processed in the past three weeks stored in three variables: numCars1, numCars2 and numCars3. Write a statement to write these values to ofstream carsData. Don't forget to use a space to separate the values and use endl to send the cursor to the next line at the end of the line.


(d) Write a statement to close the ofstream carsData

Explanation / Answer

please rate - thanks


any question ask


(a) Write a statement to create an ofstream named carsData.


ofstream carsData;



(b) Write a statement to assign the sequential access file "cars.txt" to the ofstream carsData. Open it for writing with the ios::out option.


carsData.open("cars.txt, ios::out);



(c) Suppose we have the number of cars processed in the past three weeks stored in three variables: numCars1, numCars2 and numCars3. Write a statement to write these values to ofstream carsData. Don't forget to use a space to separate the values and use endl to send the cursor to the next line at the end of the line.


carsData<<numCars1<<" "<<numCars2<<" "<<numCars3<<endl;