Am I on the right track. I know there is not much to my code, but am I?
assignment--------
CSCI 1010 Programming Assignment 9
Write a C++ program that reads the following information from an external text file named students.dat, terminating with an end-of-file check, and stores the records in 2 vectors and 1 array. Assume that there are up to 35 students in the file.
Social Security Number (Student Number) è Integer (store this data in a vector)
Student Name è-- String (store this data in a vector)
Grade Point Average è Double (store this data in an array)
Then display to the monitor (in columns with column headings), Social Security Number, Name, and GPA in reverse order (first one listed is the last element in the array ore vector). At the end, give the total number of students and the average GPA.
You can input test data with the vi editor and check that the output is correct using the editor. Warning: don’t forget that Name is a string (and hence must use getline). Since a hard return is entered after the socialsecurity number, you will also need the .ignore function before the name is entered.
Use the file name exactly as stated above.
Place each piece of information on a separate line in students.dat
Code:
Example students.dat
111223333
John Smith
3.45
222334444
Mary Jones
3.26
444558888
Bill Kats
2.50
666778888
Nan Vulmer
3.0
Sample Output
SS Number Name GPA
666778888 Nan Vulmer 3.00
444558888 Bill Kats 2.50
222334444 Mary Jones 3.26
111223333 John Smith 3.45
Total Number of students: 4
Average GPA: 3.05
my code-------
Code:
//Matthew Tyndall
//Program 9
//Write a program that reads info from a dat file and stores it in vectors and arrays.
#include<iomanip>
#include<vector>
#include<ifstream>
#include<string>
int main ()
{//int main open
vector <string> name (35);
ifstream fileout;
vector <int> ssn (35) ;
double gpa [35];
fileout.open("students.dat");
if (filout.fail())
{
cerr << "Unable to open file." << endl;
}
for (int i = 35; i<=35; i++)
{
fileout >> ssn >> name >> gpa;