Write a C program that will be an information system for Ohi
Write a C++ program that will be an information system for Ohio Community College using classes as well as demonstrating a basic understanding of inheritance and polymorphism.
You will create a representation of an Ohio Community College information system that will contain information about the university. The university will contain a name of the university, n number of buildings, and m number of people. People can be either a student or an instructor. Every person will have a name and an age. Every student will have also have a GPA, but an instructor will NOT have a GPA. Every instructor will have an instructor rating, but a student will NOT have an instructor rating. Every building will have a name, the size in sqft (2000 sqft), and an address (stored as a string, make one up).
People will contain a method called “do_work” that will take in a random integer as a parameter that represents how many hours they will do work for. If the person is a student, a message will be printed to the screen that says “PERSON_NAME did X hours of homework.” If the person is an instructor, a message will be printed to the screen that says “Instructor PERSON_NAME graded papers for X hours.” You will need to fill in the appropriate values.
The student GPA can either be an input from the user or randomized, but it must be between 0.0 and 4.0. It cannot be preset. The instructor rating can either be an input from the user or randomized, but it must be between 0.0 and 5.0. The ages of a person can be randomized or an input, but make it realistic. You can choose whether it is randomized or user input, or both.
The university will contain a method that will print the name and address of all the buildings in its information system and another method that will print the name of all the people. The name of the university MUST be “Ohio Community College” (because we are the best).
You will manually instantiate at least 1 student, 1 instructor, and 2 buildings, then give them values and store them appropriately in the university object. You can do this in whatever fashion you wish.
You will have a menu that does at least the following:
1) Prints names of all the buildings
2) Prints names of everybody at the university
3) Choose a person to do work
4) Exit the program
Note that option 3 will require you to print another menu that gives options for each person.
You may create any other functions, methods, member variables, etc. to modularize your code and complete the lab.
You may use vectors for this assignment if you so choose.
Solution
#include <iostream>
 #include <vector>
 #include <string>
using namespace std;
// Base class
 class Person {
   
 protected:
 string name;
 int age;
   
 public:
 void setName(string name) {
 name = name;
 }
   
 void setAge(int age) {
 age = age;
 }
   
 virtual void do_work(int number){
   
 }
   
 virtual void printPerson(){
   
 }
 };
// Derived class
 class Student: public Person {
   
 private:
 float gpa;
public:
 void setGPA(float gpa) {
 gpa = gpa;
 }
float getGPA(){
 return gpa;   
 }
   
 void do_work(int number){
 // cout << name << \".. \" << number << \"hours of homework.” << endl;
 cout << name ;
 }
   
 void printPerson(){
 cout << \" Name : \" << name << \"Age :\" << age << \" GPA : \" << getGPA() << endl ;   
 }
 };
// Derived class
 class Instructor: public Person {
   
 private:
 float rating;
public:
 void setRating(float rating){
 rating = rating;   
 }
float getRating() {
 return rating;
 }
   
 void do_work(int number){
 cout << name << \"graded papers for\" << number << \"hours.\" << endl;
 }
   
 void printPerson(){
 cout << \" Name : \" << name << \" Age : \" << age << \" Rating : \" << getRating() << endl ;   
 }
 };
class Building{
 public:
 string name;
 int size;
 string address;
   
 public:
 void printBuilding(){
 cout << \" Name : \" << name << \" Address : \" << address << endl;   
 }
 };
class University{
   
 public:
 string name;
 vector<Person*> persons;
 vector<Building> buildings;
   
 public:
 void printAllBuildings(){
 cout << \" Building Details : \" << endl;
 for ( int j = 0; j < buildings.size() ; j++ ){
 buildings[j].printBuilding();
 }
 }
   
 void printAllPersonsRecord(){
 cout << \" Persons Details : \" << endl;
 for ( int i = 0; i < persons.size() ; i++ ){
 persons[i]->printPerson();
 }
 }
 };
int main ()
 {
 // Answer of Question You will manually instantiate at least 1 student, 1 instructor, and 2 buildings.
 Student student;
 Instructor instructor;
   
 student.setName(\"deepak\");
 student.setAge(12);
 student.setGPA(12.0);
instructor.setName(\"rajdev\");
 instructor.setAge(23);
 instructor.setRating(5.0);
   
 Building building;
   
 building.name=\"block1\";
 building.size = 2000;
 building.address= \"noida sector-2\";
   
 Building building2;
   
 building2.name=\"block2\";
 building2.size = 4000;
 building2.address= \"noida sector-2\";
   
 University university;
   
 university.name = \"Ohio Community College\";
 university.persons.emplace_back(&student);
 university.persons.emplace_back(&instructor);
 university.buildings.push_back(building);
 university.buildings.push_back(building2);
   
 university.printAllBuildings();
   
 university.printAllPersonsRecord();
   
 /*2. Answer of second question after insertion of first few data, take input from user and
 give them values and store them appropriately in the university object.*/
 int choice;
 bool isValidMainChoice = false;
 while(!isValidMainChoice){
 cout << \"Kindly choose one of the option from follwoing list of operations or Menu\" << endl;
 cout << \"1 : Prints names of all the buildings\"<< endl;
 cout<< \"2 : Prints names of everybody at the university\"<< endl;
 cout << \"3 : Choose a person to do work\"<< endl;
 cout << \"4 : Exit the program\" << endl;
 cin >> choice;
 cout << \"The value you entered is \" << choice << endl ;
 if(choice == 1){
 university.printAllBuildings();
 }else if(choice == 2){
 university.printAllPersonsRecord();
 }else if(choice == 3){
 int personChoice;
 bool isInputValid = false;
 while(!isInputValid){
 cout << \"Kindly choose the one of the following option to provide person\'s details.\" << endl;
 cout << \"5 : Student\" << endl;
 cout << \"6 : Instructor\" << endl;
 cin >> personChoice;
 if(personChoice == 5){
 isInputValid = true;
 string studentName;
 bool isValidName = false;
 while(!isValidName){
 cout<< \" Kindly enter Name of the student :\" << endl;
 cin>> studentName;
 if( studentName.length() == 0){
 cout<<\" Name must not be blank. Kindly re-enter the student\'s name.\" << endl;
 }else{
 isValidName = true;
 }
 }
 int age1 = 0;
 bool isValidAge1 = false;
 while(!isValidAge1){
 cout<< \" Kindly enter age of the student :\" << endl;
 cin>> age1;
 if(age1 < 0 || age1 > 100 ){
 cout<<\" Age must be geter than 0 or lessa then 100. Kindly re-enter the student\'s age.\" << endl;
 }else{
 isValidAge1 = true;
 }
 }
 float gpa ;
 bool isValidGPA = false;
 while(!isValidGPA){
 cout<< \" Kindly enter GPA of the student :\" << endl;
 cin>> gpa;
 if(gpa < 0.0 || gpa > 4.0 ){
 cout<<\" GPA must be geter than 0.0 or less then 4.0. Kindly re-enter the Student GPA.\" << endl;
 isValidGPA = false;
 }else{
 isValidGPA = true;
 }
 }
 Student student;
 student.setName(studentName);
 student.setAge(age1);
 student.setGPA(gpa);
 university.persons.emplace_back(&student);
 university.printAllPersonsRecord();
 }else if(personChoice == 6){
 isInputValid = true;
 string instructorName;
 bool isValidName = false;
 while(!isValidName){
 cout<< \" Kindly enter Name of the instructor :\" << endl;
 cin>> instructorName;
 if( instructorName.length() == 0){
 cout<<\" Name must not be blank. Kindly re-enter the instructor\'s name.\" << endl;
 }else{
 isValidName = true;
 }
 }
   
 float rating ;
 bool isValidRating = false;
 while(!isValidRating){
 cout<< \" Kindly enter rating of the instructor :\" << endl;
 cin>> rating;
 if(rating < 0.0 || rating > 5.5 ){
 cout<<\" rating must be geter than 0.0 or less then 5.5. Kindly re-enter the instructor rating.\" << endl ;
 isValidRating = false;
 }else{
 isValidRating = true;
 }
 }
 int age2 = 0;
 bool isValidAge2 = false;
 while(!isValidAge2){
 cout<< \" Kindly enter age of the instructor :\" << endl;
 cin>> age2;
 if(age2 < 0 || age2 > 100 ){
 cout<<\" Age must be geter than 0 or lessa then 100. Kindly re-enter the instructor\'s age.\" << endl;
 }else{
 isValidAge2 = true;
 }
 }
 Instructor instructor;
 instructor.setName(instructorName);
 instructor.setAge(age2);
 instructor.setRating(rating);
 university.persons.emplace_back(&instructor);
 }else{
 cout << \"The value you entered is incorrct.Please r-enter the values.\" << endl;
 }
 }
 }else if(choice == 4){
 isValidMainChoice = true;
 cout << \" You are exits from system. Thanks You !!\" << endl;
 }
 }
 return 0;
 }






