You are on page 1of 2

#include<iostream>

#include<stdlib.h>
#include<fstream>
using namespace std;

void Heading()
{
cout << "\n.................University of Sargodha 2020
Admission.....................\n\n" << endl << endl;

void menu();
class UOS_ADDMISSION
{
private:
string name;
int Ph_no;
string Fname;
public:
void getdetails()
{
cout << "Please Enter Your name:\t";
cin >> name;
cout << "Please Enter Your Father name:\t";
cin >> Fname;
try
{
cout << "Please Enter Your Phone Number:\t";
cin >> Ph_no;
if (cin.fail())
{
throw runtime_error("Phone number must be In Digits..");
}
}
catch (runtime_error &e){
cout << e.what() << endl;
}
cout << "Do you want to save your Details(Y/N)" << endl;
char ch;
cin >> ch;
if (ch == 'y' || ch == 'Y')
{
ofstream file("Details.txt", ios::app);
file << name << "\t" << Fname << "\t" << Ph_no << endl;
cout << "Your Details have been send to University Succeefull You
will informed soon Thank you ^_^" << endl << endl;
file.close();
system("pause");
menu();
}
else
{
cout << "Your Details has not been Saved Thank you" << endl;
menu();
}
}
void showStudendts()
{
ifstream myfile("Details.txt");
while (myfile>>name>>Fname>>Ph_no)
{
cout << name << "\t" << Fname << "\t" << Ph_no << endl;
}
myfile.close();
cout <<" \t\t\t\t\t^_~"<< endl << endl;
system("pause");
menu();
}
};
void menu()
{
system("cls");
Heading();
UOS_ADDMISSION obj;
cout << "Please select the option giving below" << endl;
cout << "(1) Do you want to take Admission" << endl;
cout << "(2) See all application (Adminstator)" << endl;
cout << "(3) Exit from programme" << endl;

int option;
cin >> option;
while (option > 3 || option <= 0)
{
cout << "Wrong input please enter Again" << endl;
cin >> option;
}
switch (option)
{
case 1:
{
system("cls");
obj.getdetails();
break;

}
case 2:
{ system("cls");
obj.showStudendts();
break;
}
case 3:
{
exit(0);
break;
}
}
}
int main()
{
menu();
return 0;
}

You might also like