-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent data.cpp
50 lines (40 loc) · 1.05 KB
/
Student data.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
struct Student{
string ID;
string index;
string LName;
string FName;
float midsem;
float finalmark;
float totalmark;
};
void Reader(Student temp);
int main(){
Student pupil;
cout<<"Starting program..."<<endl;
Reader(pupil);
return 0;
}
void Reader(Student Temp){
string header;
ifstream infile("Data file.txt");
ofstream outfile("Processed data.txt");
outfile<<"INDEX NUMBER"<<"\t LAST NAME"<<"\tTOTAL MARK"<<endl;
outfile<<"---------------------------------------------------------------------------------------------------------------------"<<endl;
if(infile.is_open()){
getline(infile, header);
while(!infile.eof()){
infile>>Temp.ID>>Temp.index>>Temp.LName>>Temp.FName>>Temp.midsem>>Temp.finalmark;
Temp.totalmark = Temp.midsem + Temp.finalmark;
outfile<<Temp.index<<setw(18)<<Temp.LName<<setw(15)<<Temp.totalmark<<endl;
}
cout<<" Run sucessfully.."<<endl;
}
else cout<<"File not found";
infile.close();
outfile.close();
}