Write a C++ program that should ask the user if he/she has the student ID card or not. If the user enters ‘n’ or ‘N’, the program should display a message like “You are not allowed to enter”. If the user says ‘y’ or ‘Y’, then your program should ask him/her what is his/her department, and then display a respective message as follows:
a. If the department is CS, then display a message “Go to Block 1”
b. If the department is EE, then display a message “Go to Block 3”
c. If the department is BBA, then display a message “Go to Block 2”
d. If the department is EDU, then display a message “Go to Knowledge Center”
c++ programming exercise with solution |
#include <iostream>
using namespace std;
int main()
{
char usr_input;
string departement;
cin>>usr_input;
if (usr_input == 'y' || usr_input == 'Y')
{
cout<<"What is your Departement\n";
cout<<"CS\n";
cout<<"EE\n";
cout<<"BBA\n";
cout<<"EDU\n";
cin>>departement;
if (departement == "CS" || departement == "cs")
{
cout<<"Go to block 01";
}
else if (departement == "EE" || departement == "ee")
{
cout<<"Go to block 02";
}
else if (departement == "BBA" || departement == "bba")
{
cout<<"Go to block 03";
}
else if (departement == "EDU" || departement == "edu")
{
cout<<"Go to knowledge center";
}
}
else if (usr_input == 'n' || usr_input == 'N')
{
cout<<"Sorry You are not allowed to enter";
}
else
{
cout<<"Please Enter a valid input";
}
return 0;
}