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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{int k=0;
int i=1;
short select2=0;
ifstream inFile("inputData.csv");
ofstream outFile("output1.txt");
if(!inFile.is_open())
{
cout << "ERROR READ: input File is Open."<<'\n';
}
if(!outFile.is_open())
{
cout << "ERROR READ: output File is Open."<<'\n';
}
string firstname;
string lastname;
string ID;
string email;
string street;
string city;
string state;
string zipcode;
string telephone;
string exam1;
string exam2;
string exam3;
string Ffirstname[50];
string Llastname[50];
string IID[50];
string EEmail[50];
string Sstreet[50];
string Ccity[50];
string Sstate[50];
string Zzipcode[50];
string Ttelephone[50];
string Eexam1[50];
string Eexam2[50];
string Eexam3[50];
short select1;
cout<<"1.-Create Student Record.\n2.-Display Student Record.\n3.-Update Student Record.\n4.-Delete Student Record.\n5.-Display and Write Student Records.\n6.-Exit.\n";
cin>>select1;
(start of switch cases 1,2,4,5,6)
.....
.....
case 3:
cout<<"which student record would you like to update?\n";
cin>>select2;// select 2 is used for the new switch statement to choose the student records to be updated (values changed).
while(!inFile.eof())
{
getline(inFile,firstname,',');
getline(inFile,lastname,',');
getline(inFile,ID,',');
getline(inFile,email,',');
getline(inFile,street,',');
getline(inFile,city,',');
getline(inFile,state,',');
getline(inFile,zipcode,',');
getline(inFile,telephone,',');
getline(inFile,exam1,',');
getline(inFile,exam2,',');
getline(inFile,exam3,'\n');
if(inFile.eof()) break;
Ffirstname[k]=firstname;
Llastname[k]=lastname;
IID[k]=ID;
EEmail[k]=email;
Sstreet[k]=street;
Ccity[k]=city;
Sstate[k]=state;
Zzipcode[k]=zipcode;
Ttelephone[k]=telephone;
Eexam1[k]=exam1;
Eexam2[k]=exam2;
Eexam3[k]=exam3;
cout<<Ffirstname[k]<<"\n"<<Llastname[k]<<"\n"<<IID[k]<<"\n"<<EEmail[k]<<"\n"<<Sstreet[k]<<"\n"<<Ccity[k]<<"\n"<<Sstate[k]<<"\n"<<Zzipcode[k]<<"\n"<<Ttelephone[k]<<"\n"<<Eexam1[k]<<"\n"<<Eexam2[k]<<"\n"<<Eexam3[k]<<"\n\n";
k++;
}
...
...
else if (select1>6)//6=number of cases in menu.
{
cout<<"Please try again later.";
exit(0);
}
inFile.close();
outFile.close();
}
|