C++ program.The program contains 4 options for user to choose.First is addStudent,which when selected asks for contact information,the second option addTeacher asks for same contact information(we have to use inheritance here) and asks for years of Experience.The third and fourth options are display Student and display Teacher respectively which displays all the data entered.The student and teacher are different classes where teacher extends student.Both student and teacher information should be stored in arrays and so display options just prints out the array
The required answer is given below in case of any doubt you can ask me in comments also in case of corrections required do let me know. Please do upvote as it affects my career a lot.
main.cpp
#include<iostream>
using namespace std;
class Person {
public:
string name;
int age;
Person()
{
}
Person(string name,int age)
{
this->name = name;
this->age = age;
}
};
class Teacher : public Person {
public:
string course;
Teacher() : Person()
{
}
Teacher(string name, int age, string course):Person(name,age)
{
this->course = course;
}
void display()
{
cout<<"Name : "<<this->name<<endl;
cout<<"Age : "<<this->age<<endl;
cout<<"Course : "<<this->course<<endl;
}
};
class Student : public Person
{
string degree;
public:
Student() : Person()
{
}
Student(string name, int age, string degree):Person(name,age)
{
this->degree= degree;
}
void display()
{
cout<<"Name : "<<this->name<<endl;
cout<<"Age : "<<this->age<<endl;
cout<<"Degree : "<<this->degree<<endl;
}
};
int main()
{
int count = 0,count1 = 0,ch;
string name,degree,course;
Student stud[10000];
Teacher teach[10000];
int age;
while(ch!=5)
{
cout<<"\n-----------MENU-----------\n";
cout<<"1)Add a new Student \n";
cout<<"2)Add a new Teacher \n";
cout<<"3)Display all Student \n";
cout<<"4)Display all Teachers \n";
cout<<"5)Exit \n";
cout<<"Enter Your choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter Name : ";
cin>>name;
cout<<"Enter Age : ";
cin>>age;
cout<<"Enter Degree : ";
cin>>degree;
stud[count++] = Student(name,age,degree);
cout<<"\nRecord Added Successfully\n";
break;
case 2:
cout<<"Enter Name : ";
cin>>name;
cout<<"Enter Age : ";
cin>>age;
cout<<"Enter Course : ";
cin>>course;
teach[count1++] = Teacher(name,age,course);
cout<<"\nRecord Added Successfully\n";
break;
case 3:
cout<<"Printing all Students : \n"<<endl;
for(int i=0 ; i<count;i++)
{
stud[i].display();
cout<<endl;
}
break;
case 4:
cout<<"Printing all Teachers : \n"<<endl;
for(int i=0 ; i<count1;i++)
{
teach[i].display();
cout<<endl;
}
break;
case 5:
exit(0);
}
}
return 0;
}
OUTPUT




C++ program.The program contains 4 options for user to choose.First is addStudent,which when selected asks for...
In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...
Write a contacts database program that presents the user with a menu that allows the user to select between the following options: (In Java) Save a contact. Search for a contact. Print all contacts out to the screen. Quit If the user selects the first option, the user is prompted to enter a person's name and phone number which will get saved at the end of a file named contacts.txt. If the user selects the second option, the program prompts...
Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....
C++ Do not use "cin" to get the names from the user. Use "getline()". Name Arranger Write a program that asks for the user’s first, middle, and last names. The names should be stored in three different character arrays. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example,...
In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...
Total Sales Design a program that asks the user to enter a store’s sales for each day of the week. The amounts should be stored in an array. Use a loop to calculate the total sales for the week and display the result. Need: variable lists, IPO Chart, pseudocode, Flowchart, and working Python code. 2. Lottery Number Generator Design a program that generates a 7-digit lottery number. The program should have an Integer array with 7 elements. Write a loop...
In a file called First SecondNext.java, write a program that: • Asks the user to enter a string that contains at least five letters. It is OK if your program crashes when the user enters a string with length less than 5. • Stores that string in a variable called s. • Creates a variable called "first", and sets it equal to the first letter of s. • Creates a variable called "second", and sets it equal to the second...
Write a C++ program that generates an array filled up with random positive integer number ranging from 15 to 20, and display it on the screen. After the creation and displaying of the array , the program displays the following: [P]osition [R]everse, [A]verage, [S]earch, [Q]uit Please select an option: Then, if the user selects: -P (lowercase or uppercase): the program displays the array elements position and value pairs for all member elements of the array. -R (lowercase or uppercase): the...
C# Write a program that takes a list of information and grades of the students of a class and perform some processing. Take the following steps to write the program. The program must give the user two options such as a menu. At the beginning of the program must ask the following from the user: Which task you want to do (choose an option between 1-2), 1- Entering new information 2- Searching a student If the user types something rather...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...