Send help

All shorts of lost. PLEASE HELP!!


Background:
A local college stores information about students pursuing a degree in Computer Information Systems in a
file named cisdegree.txt (a sample is included with this laboratory assignment). Each line in the text
file includes a student’s identification number (eight digits), last name, first name, middle initial, grade point
average, and a single character representing one of the following degree options:
A – applications N – networking P – programming W – web development
An example line:
10203846 Hart Bartholomew S 3.27 P
The college wants the data from this file divided into four separate files, one for each degree program –
appmajors.txt, netmajors.txt, progmajors.txt, and webmajors.txt – with each file
listing the students in that particular major. Since each file will only include the students from one major,
you don’t need to include the character for major. For example, the aforementioned student would be
included in the file progmajors.txt with the following line:
10203846 Hart Bartholomew S 3.27

^^that is the background part of the lab.
the steps are:
1.Declare your variables(there is a list of variables to use).
2.Open each file
3.Use number formatting with each output file
4.Create the input-driven loop
5.Process an input record in the loop body
6.Close the files


And what I have so far based on my notes...



#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
ifstream inFile;
ofstream newFile;
int val1, val2, val3;


inFile.open("cisdegree.txt");
if (inFile.fail())
{
cout << "Error opening input file.\n";
exit(1); // 1 indicates an error
}
newFile.open("New.txt");

inFile >> val1 >> val2 >> val3;
newFile << val1 << " " << val2 << " " << val3 << endl;

inFile.close();
newFile.close();

return 0;
}
Last edited on
Do not double-post. That is counter-productive. Other thread: http://www.cplusplus.com/forum/beginner/232346/
you say that but dont help... now that is counter-productive.
Topic archived. No new replies allowed.