Question

In: Computer Science

Write a C++ program that will be an information system for Oregon State University using classes...

Write a C++ program that will be an information system for Oregon State University using classes as well as demonstrating a basic understanding of inheritance and polymorphism.
You will create a representation of an Oregon State University 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 (preferred the real value which you need to look up), and an address (stored as a string, also preferred to look this 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 “Oregon State University” (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.
(10 pts) Program Style/Comments
In your implementation, make sure that you include a program header in your program, in addition to proper indentation/spacing and other comments! Make sure you review the style guidelines for this class, and begin trying to follow them, i.e. don’t align everything on the left or put everything on one line! Also view the “Things not to do in the code” page and the “Things you need to do in your code” page as you will be held to these.

Add an option to save the information system to a file, and add an option to read a saved information system from a file so that you can close the program, but not lose information. This will also require you to be able to add people and/or buildings to the program during runtime. This is an all or nothing extra credit (you will not get partial points for partial completion).

Solutions

Expert Solution

Screenshot of code:

Screenshot of output:

Code to copy:

#include "stdafx.h" // use only if using visual studio

#include<iostream>
#include<stdlib.h>
#include<string>
#include<math.h>

using namespace std;

//Class university is declared
class university
{
public:
//Data members declared
string nameUniv;
int numberBuild, numberPeople;
string buildName, address;
string sname[10], instructorname[10];
int size, age[10], instage[10];
float GPA[10], rating[10];

//Constructor is defined
university()
{
nameUniv = "Oregon State University";
numberBuild = 5;//n number of buildings
numberPeople = 10;//m number of peoples
}

//Method is defined to get the name of the students
void getStudentName()
{
const int LOW = 0.0;
const int HIGH = 4.0;
const int LOW1 = 15;
const int H1 = 25;
srand(3);
sname[0] = "jack mark"; age[0] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[0] = rand() % (HIGH - LOW + 1) + LOW;
sname[1] = "john rock"; age[1] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[1] = rand() % (HIGH - LOW + 1) + LOW;
sname[2] = "Peter Adams"; age[2] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[2] = rand() % (HIGH - LOW + 1) + LOW;
sname[3] = "Ricky Ponting"; age[3] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[3] = rand() % (HIGH - LOW + 1) + LOW;
sname[4] = "Methew Haden"; age[4] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[4] = rand() % (HIGH - LOW + 1) + LOW;
sname[5] = "Jovial Chahal"; age[5] = rand() % (H1 - LOW1 + 1) + LOW1;
GPA[5] = rand() % (HIGH - LOW + 1) + LOW;
}

//Method is defined to get the name of the instructors
void getInstructorname()
{
const int LOW = 0.0;
const int HIGH1 = 5.0;
const int LOW1 = 28;
const int H1 = 70;
srand(3);
instructorname[0] = "Isabel Garvin"; instage[0] = rand() % (H1 - LOW1 + 1) + LOW1;
rating[0] = rand() % (HIGH1 - LOW + 1) + LOW;
instructorname[1] = "Peter Adams"; instage[1] = rand() % (H1 - LOW1 + 1) + LOW1;
rating[1] = rand() % (HIGH1 - LOW + 1) + LOW;
instructorname[2] = "Adam Gilchrist"; instage[2] = rand() % (H1 - LOW1 + 1) + LOW1;
rating[2] = rand() % (HIGH1 - LOW + 1) + LOW;
instructorname[3] = "Serena Villiams"; instage[3] = rand() % (H1 - LOW1 + 1) + LOW1;
rating[3] = rand() % (HIGH1 - LOW + 1) + LOW;
instructorname[4] = "Maria Sharapoa"; instage[4] = rand() % (H1 - LOW1 + 1) + LOW1;
rating[4] = rand() % (HIGH1 - LOW + 1) + LOW;
}

//Method to print the building details
void printBuild(university U[])
{
cout << "\n--- Names of buildings ---\n";
for (int i = 0; i < numberBuild; i++)
{
cout << "Building name:\t" << U[i].buildName << "\n";
cout << "Address:\t" << U[i].address << "\n";
}
}

//Method to print the name of the students
void printStudentName()
{
cout << "\n--- Name of Students ---\n";
for (int i = 0; i < 6; i++)
cout << "\nName : " << sname[i] << "\tAge : " << age[i] << "\tGrades : " << GPA[i];
}

//Method to print the name of the instructors
void printInstructorName()
{
cout << "\n--- Name of Instructors ---\n";
for (int i = 0; i < 5; i++)
cout << "\nName : " << instructorname[i] << "\tAge : " << instage[i] << "Ratings : " << rating[i];
}
};


class people : university
{
public:
//Declare the data members
string peopleName;
const int LOW1 = 1;
const int H1 = 8;

  
int age, hours[20];
float GPA;
float rating;

//Define the method do_work to check out the working hours of instructor and student
void do_work(people P[], char p)
{
university u;
//Prints the working hour of student
if (p == 'S')
for (int i = 0; i < 6; i++)
{
hours[i] = rand() % (H1 - LOW1 + 1) + LOW1;
cout << "Student " <<university::sname[i] << " did " << hours[i] << " of homework\n";
}
else
//Prints the working hours of instructor
for (int i = 0; i < 5; i++)
{
hours[i] = rand() % (H1 - LOW1 + 1) + LOW1;
cout << " Instructor " << instructorname[i] << " graded papers for" << hours[i] << ".\n";
}
}
};

//start the main function
int main()
{
//Declare variables
int op;
char ch;
university U[10], U1;
char person;

people P[5], p1;
U1.getStudentName();
U1.getInstructorname();

U[0].buildName = " AB 6 Small Shed-Berry Creek ";
U[1].buildName = "AB Adair Hay Store-Loaf S";
U[2].buildName = "Apiary (Bee) Building";
U[3].buildName = "Animal Physiology Lab";
U[4].buildName = "AS Adair Barn #2-Soap CR";
U[0].address = "27280 TAMPICO RD, CORVALLIS, OR 97330 ";
U[1].address = "28120 BEEF BARN RD,CORVALLIS, OR 97330";
U[2].address = "681 SW 26TH STREET CORVALLIS, OR 97331";
U[3].address = "3550 CAMPUS WAY CORVALLIS, OR 97330";
U[4].address = "2750 SW CAMPUS WAY CORVALLIS, OR 97331";

do
{
cout << "\n\t\t" << U1.nameUniv << "\n";
cout << "\n\t1) Prints names of all the buildings";
cout << "\n\t2) Prints names of everybody at the university";
cout << "\n\t3) Choose a person to do work";
cout << " \n\t4) Exit the program \n choose option : ";
cin >> op;
switch (op)
{
case 1: U1.printBuild(U); break;
case 2: cout << "\n Choose 1) To print students name: ";
cout << "\n Choose 2) for instructors name: ";
cin >> person;
switch (person)
{
case '1': U1.printStudentName(); break;
case '2': U1.printInstructorName(); break;
default: cout << "\nWrong Input"; break;
}
break;
case 3: cout << "\n\tChoose S) student \n\tI)Instructor : "; cin >> person;
switch (person)
{
case 'S': p1.do_work(P, person); break;
case 'I': p1.do_work(P, person); break;
default: cout << "\nWrong Input"; break;
}
break;
case 4: exit(1);
}
cout << "\nDo you want to continue ? y/n : ";
cin >> ch;
} while (ch == 'y');
system("pause");// use only if using visual studio
return 0;
}


Related Solutions

Write a C or C++ program using the fork() system call function. You will need to...
Write a C or C++ program using the fork() system call function. You will need to create 3 processes – each process will perform a simple task. Firstly, create an integer "counter" initialized to a random value between 1 and 100. Print this number to the console. This can be done by: Including the stdio.h and stdlib.h libraries Using the rand() function to generate your randomly generated number The main thread consists of the parent process. Your job is to...
Question text The Chancellor of the California State University System has recently indicated that classes in...
Question text The Chancellor of the California State University System has recently indicated that classes in the Fall of 2020 will continue to be virtual to be able to cope with the Corona Virus. Assume that all CSULB business students take a student satisfaction survey each semester. A researcher wants to compare compare two random groups of students from Fall 2019 to Fall 2020 in their satisfaction scores. The Chancellor has indicated that student satisfaction will improve with virtual classes....
Write a program for hotel booking system using C++ Program Requirement 1. You can write any...
Write a program for hotel booking system using C++ Program Requirement 1. You can write any program based on the title assigned. 2. The program must fulfill ALL the requirements below. The requirements listed below are the MINIMUM requirement. Your program may extend beyond the requirements if needed. a) Create at least one (1) base class. b) Create at least two (2) derived classes that inherit from the base class created in 2(a). c) Create at least one (1) object...
In this Question using c++, you are to develop an employee management system using classes. You...
In this Question using c++, you are to develop an employee management system using classes. You need to develop two classes: Date and Employee. The Date class has the three attributes (int): month, day, and year. The class has the following member functions: • string getDate(void): returns a string with the date information (e.g, Mach 27, 2020). In addition to these, declare and implement proper constructors, a copy constructor, a destructor, and getters and setters for all data members. The...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a motivation letter for an undergraduate program into a university to study information technology.
Write a motivation letter for an undergraduate program into a university to study information technology.
IN C++, IN C++, IN C++, IN C++, IN C++ Write the A and B classes,...
IN C++, IN C++, IN C++, IN C++, IN C++ Write the A and B classes, the properties of which will produce the expected output with the test code provided, and the characteristics of which are specified below. Note the types of pointers used in the test code. Methods of class A: - void hi () - Prints “Hi A” on the screen. - void selam() - Prints "Selam A" on the screen. Class B must inherit class A. Class...
Create a C++ code for the mastermind game using classes(private classes and public classes). Using this...
Create a C++ code for the mastermind game using classes(private classes and public classes). Using this uml as a reference.
Write a C++ program to allow the user to: 1. Create two classes. Employee and Departments....
Write a C++ program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to do the following: 1....
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT