Anda di halaman 1dari 8

#include <windows.

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

int main(){
// pwd
int pwd;
cout<<"Enter the password.........\n";
cin>>pwd;
if (pwd!=12345)
cout<<"Your Password Is Wrong....... Please Re Try\n";
else
if (pwd==12345)
{
//menu
{
int choice;
system("cls");
cout << " X Y Z University, Student Registration system\n\n";
cout << " M E N U\n";
cout << " = = = =\n";
cout<<"\n 1 :Insert new Student details\n";
cout<<" 2 :View existing Student Registration details\n";
cout<<" 3 :Quit program \n";
cout<<"\nEnter your choice: ";
while (!(cin >> choice) )
{
cout << "\nOOPS !! that's an invalid option."
<< "\nRe-Enter your choice: ";
cin.clear();
fflush(stdin);
}
return choice;
}

#ifdef _WIN32
system ("color 6a");
#endif
//student add
char FileName[20];
char openFileName[20];
string newregistration;
cout<<endl<<endl;
cout <<".....Wellcome to X Y Z University, Student Registration System.....";
cout<<endl<<endl<<endl;

string subject[4];
string firstname;
string lastname;
string nic;
string gender;
string birthday;
string homenumberorname;
string streetname;
string cityname;

string contactnumber;
string emailaddres;

double id;
cout<<"Student New Registration Number\"Should minimum than 250 \" "<<setw(9)<<s
etfill('.')<<":";
cin>>id;
cout<<endl<<endl<<endl<<endl;

cout<<" "<<endl;
cout<<" :::::::::::::............UNIVERSITY..............::::::::::::"<<endl;
cout<<" :::::::::::::................OF..................::::::::::::"<<endl;
cout<<" :::::::::::::...............X Y Z................::::::::::::"<<endl;
cout<<" ______________________________________________________________"<<endl
<<endl<<endl;

cout<<"1. Enter Student First Name "<<setw(05)<<setfill('.')<<":";


cin>>firstname;
cout<<"3. Enter Student Last Name "<<setw(5)<<setfill('.')<<":";
cin>>lastname;
cout<<"4. Enter Student NIC Number "<<setw(5)<<setfill('.')<<":";
cin>>nic;
cout<<"5. Enter Student Gender \"- MALE or FEMALE-\""<<setw(5)<<setfill('.')
<<":";
cin>>gender;
cout<<"6. Enter Student Birthday "<<setw(5)<<setfill('.')<<":";
cin>>birthday;
cout<<"7. Enter Student Address"<<setw(40)<<setfill(' ')<<" "<<endl;

cout<<setw(31)<<setfill(' ')<<"No"<<" : ";


cin>>homenumberorname;
cout<<setw(32)<<setfill(' ')<<"Street Name"<<": ";
cin>>streetname;
cout<<setw(32)<<setfill(' ')<<"City Name ."<<": ";
cin>>cityname;
cout<<"8. Enter Student E-mail "<<setw(9)<<setfill('.')<<":";
cin>>emailaddres;
cout<<endl;
cout<<"9. Enter Student Contact Number"<<setw(5)<<setfill('.')<<":";
cin>>contactnumber;
cout<<endl<<endl;

cout<<"10.Enter Student Subjects \"(Maximum 4 Subjects)\" "<<setw(5)<<setfill('


')<<" "<<endl<<endl;
cout<<" Available Subjects : 1. Internet Technology. "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 2. J2SE. "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 3. J2EE . "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 4. Networking. "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 5. 3D Animation.VB.Net."<<endl;


cout<<setw(21)<<setfill(' ')<<":"<<" 6. Adobe Photoshop. "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 7. C++. "<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 8. Java. "<<endl;


cout<<setw(21)<<setfill(' ')<<":"<<" 9. 3D Animation. "<<endl;
cout<<setw(21)<<setfill(' ')<<":"<<" 10. System Software."<<endl;

cout<<setw(21)<<setfill(' ')<<":"<<" 11. Web Designing. "<<endl;


cout<<setw(21)<<setfill(' ')<<":"<<" 12. MS Office Packages . "<<endl;
int row;
cout<<endl<<endl;
for(row=1;row<=4;row++){
cout<<"Enter Subject Numbers "<<
row<<": ";
cin>>subject[row
];
}
cout<<endl<<endl<<endl<<endl;

cout<<" ===========YOU ENTERD DETAILS=========== "<<endl<<endl;


cout<<"1. Student Registration ID "<<setw(20)<<setfill('.')<<": "<<id
<<endl;
cout<<"2. Student First Name "<<setw(20)<<setfill('.')<<": "<<firstname
<<endl;
cout<<"3. Student Last Name "<<setw(20)<<setfill('.')<<": "<<lastname
<<endl;
cout<<"4. Student NIC Number "<<setw(20)<<setfill('.')<<": "<<nic
<<endl;
cout<<"5. Student Gender "<<setw(20)<<setfill('.')<<": "<<gender
<<endl;
cout<<"6. Student Birthday "<<setw(20)<<setfill('.')<<": "<<birthday
<<endl;
cout<<"7. Student Address "<<setw(20)<<setfill('.')<<": "<<homenumbe
rorname<<", "
<<streetname<<", "<<cityname<<endl;

cout<<"8. Student Contact Number "<<setw(20)<<setfill('.')<<": "<<contactnu


mber <<endl;
cout<<"9. Student E-mail Address "<<setw(20)<<setfill('.')<<": "<<emailaddre
s <<endl<<endl;
cout<<"10.Selected Student Subjects "<<endl<<endl;
cout<<" Student Subjects 1 "<<setw(5)<<setfill('.')<<": "<<subj
ect[1]<<endl;

cout<<" Student Subjects 2 "<<setw(5)<<setfill('.')<<": "<<subj


ect[2]<<endl;
cout<<" Student Subjects 3 "<<setw(5)<<setfill('.')<<": "<<subj
ect[3]<<endl;
cout<<" Student Subjects 4 "<<setw(5)<<setfill('.')<<": "<<subj
ect[4]<<endl;

cout<<endl<<endl;
cout<<endl;

ifstream infile;
ofstream outfile;

if(id==001){
infile.open("c:\\out_reg_001.doc");
outfile.open("c:\\in_reg_001.doc");
}
if(id==002){
infile.open("c:\\out_reg_002.doc");
outfile.open("c:\\in_reg_002.doc");
}

if(id==003){
infile.open("c:\\out_reg_003.doc");
outfile.open("c:\\in_reg_003.doc");
}

if(id==004){
infile.open("c:\\out_reg_004.doc");
outfile.open("c:\\in_reg_004.doc");
}

if(id==005){
infile.open("c:\\out_reg_005.doc");
outfile.open("c:\\in_reg_005.doc");
}

if(id==006){
infile.open("c:\\out_reg_006.doc");
outfile.open("c:\\in_reg_006.doc");
}
if(id==007){
infile.open("c:\\out_reg_007.doc");
outfile.open("c:\\in_reg_007.doc");
}
outfile<<" Student Registration Number : "<<id<<endl<<endl<<endl;
outfile<<"1. Student First Name "<<setw(20)<<setfill('.')<<": "
<<firstname <<endl<<endl;;

outfile<<"3. Student Last Name "<<setw(20)<<setfill('.')<<": "


<<lastname <<endl<<endl;
outfile<<"4. Student NIC Number "<<setw(20)<<setfill('.')<<": "
<<nic <<endl<<endl;
outfile<<"5. Student Gender "<<setw(20)<<setfill('.')<<": "
<<gender <<endl<<endl;
outfile<<"6. Student Birthday "<<setw(20)<<setfill('.')<<": "
<<birthday <<endl<<endl;

outfile<<"7. Student Address "<<setw(20)<<setfill('.')<<": "<<homenu


mberorname<<", "
<<streetname<<", "<<cityname<<", "
<<emailaddres<<endl<<endl<<endl;
outfile<<"9. Student Contact Number "<<setw(20)<<setfill('.')<<": "
<<contactnumber <<endl<<endl;

outfile<<"10. Selected Student Subjects " <<endl<<endl;


outfile<<" Student Subjects 1 "<<setw(15)<<setfill('*')<<": "
<<subject[1] <<endl<<endl;
outfile<<" Student Subjects 2 "<<setw(15)<<setfill('*')<<": "
<<subject[2] <<endl<<endl;
outfile<<" Student Subjects 3 "<<setw(15)<<setfill('*')<<": "
<<subject[3] <<endl<<endl;
outfile<<" Student Subjects 4 "<<setw(15)<<setfill('*')<<": "
<<subject[4] <<endl<<endl;

infile.close();
outfile.close();
cout<<endl<<endl;

cout << "\nEnter the name of the file you want to create: ";
cin >> FileName;
ofstream Students(FileName, ios::out);
Students <<id << "\n" <<firstname <<"\n" <<lastname << "\n"<<birthday <<"\n"
<<nic <<"\n" <<gender <<"\n" <<homenumberorname <<"\n" <<contactnumber << "\n"
<<emailaddres <<"\n" <<subject[1] <<"\n" <<subject[2] <<"\n"<<subject[3] <<"\n"
<<subject[4] ;

cout << "\n\n";


cout<<"Student Registration Successful.........................Thank You ." <<en
dl<<endl<<endl;
#ifdef _WIN32
system ("color 1f");
#endif
//student details view
{
cout << "Enter the name of the file you want to open: ";
cin >> openFileName;

ifstream (openFileName) >> id >> firstname >> lastname >> nic >> birthday >
> gender >> homenumberorname >> contactnumber >> emailaddres >> subject[1] >> su
bject[2] >> subject[3] >>subject[4];

cout << "\nStudent Registration ID: " << id;


cout << "\nStudent First Name: " << firstname;
cout << "\nStudent Last Name: " << lastname;
cout << "\nStudent NIC Number: " << nic;
cout << "\nStudent Gender : " << gender;
cout << "\nStudent Birthday: " << birthday;
cout << "\nEnter Student Address: " << homenumberorname;
cout << "\nStudent Contact Number: " << contactnumber;
cout << "\nStudent E-mail Address: " << emailaddres ;
cout << "\nSelected Student Subject 1: " << subject[1];
cout << "\nSelected Student Subject 2: " << subject[2];
cout << "\nSelected Student Subject 3: " << subject[3];
cout << "\nSelected Student Subject 4: " << subject[4];

cout << "\n\n";


}
}

return (0);
}

Anda mungkin juga menyukai