C++ Program:
#include <iostream>
#include <string>
using namespace std;
// Person class
class Person
{
public:
// name data member
string name;
// member function to print
void print() {
cout<<"Person
class.\n";
}
};
class Student : public Person
{
public:
// gpa data member
double gpa;
// Constructor for Student class
Student(string n, double g) {
name = n;
gpa = g;
}
// member function to print (overrided function)
void print() {
cout<<"Student
class.\n";
cout<<"Student Name:
"<<name<<"\n";
cout<<"Student Gpa:
"<<gpa<<"\n";
}
};
class Employee : public Person
{
public:
// salary data member
double salary;
// Constructor for Employee class
Employee(string n, double s) {
name = n;
salary = s;
}
// member function to print (overrided function)
void print() {
cout<<"Employee
class.\n";
cout<<"Employee Name:
"<<name<<"\n";
cout<<"Employee Salary:
"<<salary<<"\n";
}
};
// main method to demonstrate
int main()
{
Student student("Chandan",8.2);
student.print();
cout<<"\n";
Employee emp("Ankit",5500.0);
emp.print();
return 0;
}
Sample input and output:
Screenshot of code:
If the answer helped please upvote, it means a lot and for any query please comment.
Using C++ Instructions Person Student Employee Write a program that simulates the three classes defined as...
a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...
In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....
2- Write a program that has a Person class, a Student class, that is derived from Person, and a Faculty class, derived from Person as well, with the following specifications: The Person class has the following members: a. An integer private member variable named SSN. b. Two string protected member variables named firstName and lastName. C. An integer protected member variable named age. d. A constructor that takes SSN, first name, last name, and age as parameters. e. A constructor...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...
Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...
- Classes Write a C++ program that creates a class called Date that includes three pieces of information as data members, namely: month (type int) day (type int) year (type int). Program requirements: - Provide set and a get member functions for each data member. - For the set member functions assume that the values provided for the year and day are correct, but in the setMonth member function ensure that the month value is in the...
using c/c++ Q1 (15 Marks) Console Application for Student Data 1- Write a function named Average that Receives two integer numbers as parameter and returns the average Is used in a main function. Main() stays in a loop and asks user to enter 2 numbers and then shows the average using the Average function above Define a class named Student with following members: private data: 2 grades and a GPA (average). public constructor to initialize the members a public function...
Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....
Write three object-oriented classes to simulate your own kind of team in which a senior member type can give orders to a junior member type object, but both senior and junior members are team members. So, there is a general team member type, but also two specific types that inherit from that general type: one senior and one junior. Write a Python object-oriented class definition that is a generic member of your team. For this writeup we call it X....