Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q.The College of Computer has requested a new system to inform the applicants if

ID: 3766508 • Letter: Q

Question

Q.The College of Computer has requested a new system to inform the applicants if they where accepted or not. The system admin and the applicants themselves can access the system.

Learning Objective(s)
• Write efficient algorithms to solve the problem.
• To gain experience writing programs in visual C++.
• Practice simple data structure design in visual C++
• .Usage function isdigit() .

As a start, the main menu will appear to the user as follows:
Welcome to CoC,,
If you are the admin, please press 1.
If you are an applicant, please press 2. Press 0 to Exit.
Please enter you choice:
When the user enters 1 he will be directed to the system admin menu, and if he entered 2 he will
be directed to the applicants menu. If he chooses 0 the program will stop.
The System Admin:
System admin will be able to enter the accepted student’s name, address, telephone and email
and give them a student ID. He also can delete student information from the list. Another option
for him is to send an acceptance message to a specific applicant as follows:
Dear Mais Mohammed,
Congratulation, You have been accepted as a student in College of Computer, Qassim
University. Your information is
Address: ARrass
Phone: 3330000
Email: mais@gmil.com
Student ID: 4341100
Good Luck

-----------------------------------------------------------------------------------------

Sample output:
Here is a sample output of the program, words in bold are entered by the user.
Welcome to CoC,,
If you are the admin, please press 1.
If you are an applicant, please press 2.
Press 0 to Exit.
Please enter you choice: 1
You are a system admin
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 1
Please enter the student information
Name : Mais Mohammad
Address: Arrass
Phone: 3330000
Email: mais@gmail.com
Student ID: 4341100
Information has been saved successfully.

Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 1
Please enter the student information
Name : Samar Nasser
Address: Arrass
Phone: 3331111
Email: samar@gmail.com
Student ID: 4341122
Information has been saved successfully.
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 2
Please enter a student ID to delete: 4341111
Sorry, the student with this number can’t be found.
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 2
Please enter a student ID to delete: 4341122
Are you sure you want to delete Samar information? N
No deletion.
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.

Your option: 2
Please enter a student ID to delete: 4341122
Are you sure you want to delete Samar information? Y
The student information has been deleted Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 3
Please enter the student ID: 4341111
Sorry, the student with this number can’t be found.
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 3
Please enter the student ID: 4341100
The following message will be sent..
Dear Mais Mohammad,
Congratulation, You have been accepted as a student in College of Computer, Qassim
University. Your information is
Address: Arrass
Phone: 3330000
Email: mais@gmil.com
Student ID: 4341100
Good Luck
Please choose an option from the menu bellow:
1- Enter a new student.
2- Delete a student.
3- Send a message to a student.
4- Back to the main menu.
Your option: 4

If you are the admin, please press 1.
If you are an applicant, please press 2.
Press 0 to Exit.
Please enter you choice: 2
You are an applicant.
Please choose an option from the menu bellow:
1- Search for your name.
2- Back to the main menu.
Your option: 1
Please enter your name: Samar Nasser.
Sorry, we can’t find your name in the database, please check the spelling or contact the
student affair in CoC.
Please choose an option from the menu bellow:
1- Search for your name.
2- Back to the main menu.
Your option: 1
Please enter your name: Mais Mohammad
Dear Mais Mohammad,
Congratulation, You have been accepted as a student in College of Computer, Qassim
University. Your information is
Address: ARrass
Phone: 3330000
Email: mais@gmil.com
Student ID: 4341100
Good Luck
Please choose an option from the menu bellow:
1- Search for your name.
2- Back to the main menu.
Your option: 2
If you are the admin, please press 1.
If you are an applicant, please press 2.
Press 0 to Exit.

Please enter you choice: 0
Thank you for using out System, Good Bye.

-----------------------------------------------------------------------

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;
struct Node
{
   string name, address, phone, email, id;
   Node *next;
  
};

int main() {
   ios::sync_with_stdio(false);
   int choice1, choice2;
   Node *root = new Node;
   cout << "Welcome to CoC,," << endl;
   do {
       cout << "If you are the admin, please press 1." << endl
               << "If you are an applicant, please press 2." << endl
               << "Press 0 to Exit." << endl;

       cout << "Please enter your choice: " ;
       cin >> choice1;
       switch(choice1) {
           case 1:
                   cout << "You are a system admin" << endl;
                   do {
                       cout << "Please choose an option from the menu below: " << endl;
                       cout << "1- Enter a new student." << endl;
                       cout << "2- Delete a student." << endl;
                       cout << "3- Send a message to a student." << endl;
                       cout << "4- Back to the main menu." << endl;

                       cout << "Your option: ";
                       cin >> choice2;
                       switch(choice2) {
                           case 1:
                                   {
                                       Node *newStudent = new Node;
                                       cout << "Please enter the student information" << endl;
                                       cout << "Name: ";
                                       cin >> newStudent->name;
                                       cout << "Address: ";
                                       cin >> newStudent->address;
                                       cout << "Phone: ";
                                       cin >> newStudent->phone;
                                       cout << "Email: ";
                                       cin >> newStudent->email;
                                       cout << "Student ID: ";
                                       cin >> newStudent->id;
                                       Node *iterator = root;
                                       while (iterator->next != 0) {
                                           iterator = iterator->next;
                                       }
                                       iterator->next = newStudent;
                                       cout << "Information has been saved successfully." << endl;

                                   }

                                   break;
                           case 2:
                                   {
                                       string id;
                                       bool flag = false;
                                       cout << "Please enter a student ID to delete: ";
                                       cin >> id;
                                       Node *iterator = root, *previous;
                                       while (iterator->next != 0) {
                                           previous = iterator;
                                           iterator = iterator->next;
                                           if (iterator->id == id) {
                                               flag = true;
                                               cout << "Are you sure you want to delete "<< iterator->name <<" information?" ;
                                               char choice;
                                               cin >> choice;
                                               if (choice == 'Y') {
                                                  
                                                   previous->next = iterator->next;
                                                   delete iterator;
                                                   cout << "The student information has been deleted" << endl;
                                               }
                                               else {
                                                   cout << "No deletion" << endl;
                                               }
                                               break;

                                           }
                                       }
                                       if (!flag) {
                                           cout << "Sorry, the student with this number can’t be found." << endl;
                                       }
                                       break;

                                   }
                           case 3:
                                   {
                                       string id;
                                       bool flag;
                                       cout << "Please enter a student ID: ";
                                       cin >> id;
                                       Node *iterator = root;
                                       while (iterator->next != 0) {
                                           iterator = iterator->next;
                                           if (iterator->id == id) {
                                               flag = true;
                                               cout << "The following message will be sent.." << endl;
                                               cout << "Dear " << iterator->name << "," << endl;
                                               cout << "Congratulation, You have been accepted as a student in College of Computer, Qassim" << endl << "University. Your information is" << endl;
                                               cout << "Address: " << iterator->address << endl;
                                               cout << "Phone: " << iterator->phone << endl;
                                               cout << "Email: " << iterator->email << endl;
                                               cout << "Student ID: " << iterator->id << endl;
                                               cout << "Good Luck" << endl;
                                               break;
                                           }
                                       }
                                       if (!flag) {
                                           cout << "Sorry, the student with this number can’t be found." << endl;
                                       }
                                       break;
                                   }
                       }

                   } while (choice2 != 4);
                   break;
           case 2:
                   {
                       cout << "You are an applicant." << endl;
                       do {
                           cout << "Please choose an option from the menu below:" << endl;
                           cout << "1- Search for your name." << endl;
                           cout << "2- Back to the main menu." << endl;

                           cout << "Your option: ";
                           cin >> choice2;
                           switch(choice2) {
                               case 1:
                                   {
                                       cout << "Please enter your name: " ;
                                       string name;
                                       bool flag = false;
                                       cin >> name;
                                       Node *iterator = root;
                                       while (iterator->next != 0) {
                                           iterator = iterator->next;
                                           if (iterator->name == name) {
                                               flag = true;
                                               cout << "Dear " << iterator->name << "," << endl;
                                               cout << "Congratulation, You have been accepted as a student in College of Computer, Qassim" << endl << "University. Your information is" << endl;
                                               cout << "Address: " << iterator->address << endl;
                                               cout << "Phone: " << iterator->phone << endl;
                                               cout << "Email: " << iterator->email << endl;
                                               cout << "Student ID: " << iterator->id << endl;
                                               cout << "Good Luck" << endl;
                                               break;
                                           }
                                       }
                                       if (!flag) {
                                           cout << "Sorry, we can’t find your name in the database, please check the spelling or contact the student affair in CoC." << endl;
                                       }
                                       break;
                                   }
                           }
                       } while (choice2 != 2);
                      
                   }

       }
   } while (choice1 != 0);
   cout << "Thank you for using our system, Good Bye." << endl;
}