C++ PROGRAMMING Person, Student and Teacher objects, where Person needs to be de
ID: 3860891 • Letter: C
Question
C++ PROGRAMMING
Person, Student and Teacher objects, where Person needs to be declared as an abstract base class and Student & Teacher should be declared as derived class.
If user choose the Administrator menu then system will display another submenu, which will show the following submenu options:
1) Create Student Record
2) Display All Student Records
3) Display All Students by Last Name
4) Display Specific Student Record
5) Modify Student Record
6) Delete Student Record
7) Create Teacher Record
8) Display All Teacher Records
9) Display Specific Teacher Record
10) Modify Teacher Record
11) Delete Teacher Record
12) Return to Main Menu
Data storage: data can be stored in a text file. Therefore, you must use the file read and write operations for data retrieval and storage. For this system, three files required: Student.txt, Teacher.txt
Explanation / Answer
/******************************************************************************
C++ Compiler.
Code, Compile, Run and Debug C++ program .
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
void main()
{
int option; // user's entered option will be saved in this variable
do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << "1) Administrator Menu " << endl;
cout << "2) User Menu " << endl;
cout << "3) Exit Program " << endl;
//Prompting user to enter an option according to menu
cout << "Please select an option : ";
cin >> option; // taking option value as input and saving in variable "option"
if(option == 1) // Checking if user selected option 1
{
//Display some web browsers list
cout << "1) Create Student Record" <<endl;
cout << "2) Display All Student Records" <<endl;
cout << "3) Display All Students by Last Name" <<endl;
cout << "4) Display Specific Student Record" <<endl;
cout << "5) Modify Student Record" <<endl;
cout << "6) Delete Student Record" <<endl;
cout << "7) Create Teacher Record" <<endl;
cout << "8) Display All Teacher Records" <<endl;
cout << "9) Display Specific Teacher Record" <<endl;
cout << "10) Modify Teacher Record" <<endl;
cout << "11) Delete Teacher Record" <<endl;
cout << "12) Return to Main Menu" <<endl;
cin >> option; // taking option value as input and saving in variable "option"
if(option==12)
continue;
if(option==1)
{
// create student Record
Student s1 = new Student();
s1.setName("viven");
s1.setAge(20);
ofstream myfile;
myfile.open ("student.txt");
myfile << s1; //object serialzed to file
myfile.close();
}
if(option==2)
{
std::ifstream input( "student.txt" );
for( std::string line; getline( input, line ); )
{
cout<<line;
}
}
}
else if(option == 2) // Checking if user selected option 2
{
//Displaying top sites
cout << "Google" << endl;
cout << "Facebook" << endl;
cout << "Youtube" << endl;
cout << "Yahoo" << endl;
}
else if(option == 3) // Checking if user select
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.