I am trying to understand this assignment. Im reading my book and the lecture notes the prof. puts online but I am stuck. Could you help me please?
assignment:
CSCI 1010 Programming Assignment 8
A. Purpose
Write a C++ program that uses files and a function (Read Chapter 11)
B. Due Date: 8p.m. on Monday 11/20/06
C. APSU-Rent-A-Car keeps information on each of its rental cars in a file named cars.dat. Each line of the file(cars.dat) consists of a stringthat is a three-symbol serial number for a car and the number of miles that car has been driven to date. Write a C++ program named a8YourLastname.cpp that reads information from cars.dat and produces two output files named under50.dat and 50plus.dat. under50.dat contains the serial numbers (one per line) of all cars that have under 50000 miles driven and 50plus.dat has the serial numbers(one per line) of all cars that have 50000 or more miles driven. An example of the three files is on page 269.
The program has these additional requirements:
1. The program must include a void function that is passed the file steam variable and the serial number. The function would write the serial number to the proper file. An example header for the function would be:
void outputfile (ofstream& fout, string serial_number)
The function would be passed from main the correct file stream variable associated with under50.dat or 50plus.dat and would write the passed serial number to the file.
See pages 260-261 for information on passing file streams on parameter lists. Also see slides 20 and 21 on Chapter 7 slides.
2. The main function will
(1) Open files (i.e., cars.dat, under50.dat, 50plus.dat) for input and output.
(2) Read information form the file cars.dat using an appropriate loop structure.
(3) within the loop call the Outputfile function passing it the correct file stream based on the miles driven.
(3) Close all the files.
3. Coding style (clarity, indentation, comments, spelling, etc.)
(1) Add comments including program’s name, purpose, and author.
(2) Add comments for each variable and function.
what i have so far:
Code:#include <iostream> #include <fstream> using namespace std; void outputfile (ofstream & fileout, string serial); //function declaration int main () {//int main open fileout.open("cars.dat"); fileout.open("under50.dat"); fileout.open("50plus.dat");