Lab 02: SEQUENTIAL ACCESS FILES Write the statement you are asked to write in ea
ID: 3539652 • 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 2
There are four departments in the Computer Technologies Division in a community college. We want a program to analyze the number of certificates they awarded in the past three years. The data are stored in the file %u201Ccertificates.txt%u201D:
17 19 20
28 25 26
15 15 17
31 32 25
Each row in this file is the data for one department. The first, second, and third number in each row is the number of certificates awarded in the first, second and third year, respectively.
Instead of writing a complete program, please write the following statements:
(a) Write a statement to create an ifstream named certData.
(b) Write a statement to assign the sequential access file %u201Ccertificates.txt%u201D to the ifstream certData. Open it for reading with the ios::in option.
(c) Write a statement to read three values from the ifstream certData. Store the first value in a variable named certsYr1, the second value in a variable named certsYr2 and the third value in a variable named certYr3.
(d) Write a statement to close the ifstream certData.
Explanation / Answer
please rate - thanks
any questions ask
(a) Write a statement to create an ifstream named certData.
ifstream certData
(b) Write a statement to assign the sequential access file %u201Ccertificates.txt%u201D to the ifstream certData. Open it for reading with the ios::in option.
ifstream.open("Ccertificates.txt", ios::in);
(c) Write a statement to read three values from the ifstream certData. Store the first value in a variable named certsYr1, the second value in a variable named certsYr2 and the third value in a variable named certYr3.
certData>>certsYr1>>certsYr2>>certYr3
(d) Write a statement to close the ifstream certData.
certData.close();
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.