Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.cpp #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions Project_Flies/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,35 @@ int num = 0;

int main()
{
int choice;
cout << "\n\n--------------------------------------------------------------------" << endl;
cout << " Training Schedule Management System " << endl;
cout << "--------------------------------------------------------------------" << endl;
cout << "\n\n\t\tWelcome To Home Page" << endl;
cout << "\n\t\tPress 1 --> Admin Login" << endl;
cout << "\t\tPress 2 --> Faculty Login" << endl;
cout << "\t\tPress 3 --> Exit" << endl;
cout << "\nPlease Enter Your Choice : ";
cin >> choice;

if (cin.fail())
bool repeat{ true };
const string prompt
{
cin.clear();
cin.ignore(512, '\n');
cout << "\nPlease enter a number!!" << endl;
main();
}
else
"\n"
"\n--------------------------------------------------------------------"
"\n Training Schedule Management System "
"\n--------------------------------------------------------------------"
"\n\n\n\t\tWelcome To Home Page"
"\n\n\t\tPress 1 --> Admin Login"
"\n\t\tPress 2 --> Faculty Login"
"\n\t\tPress 3 --> Exit "
"\n\nPlease Enter Your Choice : "
};

while(repeat)
{
int choice;
cout << prompt;
cin >> choice;

while (cin.fail())
{
cin.clear();
cin.ignore(512, '\n');
cout << "\nPlease enter a number!!" << endl;
cout << prompt;
cin >> choice;
}

switch (choice)
{
case 1:
Expand All @@ -50,8 +59,11 @@ int main()
break;
default:
cout << "\nPlease select from the options given above" << endl;
main();
repeat = true;
continue; //Repeat loop.
}

repeat = false;
}
}

Expand Down Expand Up @@ -145,4 +157,4 @@ void facultyLogin() //UTC-007 & AA-001
}
main();
}
}
}