In: Computer Science
create a C++ program using Visual Studio that could be used by a college to track its courses. In this program, create a CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Create a child (sub class) class named LabCourse, that inherits all fields from the the CollegeCourse class, includes one more field that holds a lab fee charged in addition to the tuition. Create appropriate functions for these classes, and write a main() function that instantiates and uses objects of each class. Save the file as Courses.cpp. Compile this application using Visual Studio and run it to make sure it is error free. Please attach your project folder in a zipfile when submitting. GRADING RUBRIC: - define a class named CollegeCourse - private fields for department, course number, credit hours, and tuition - public function(s) setting the private fields - public function that displays a CollegeCourse's data - define a class named LabCourse - inherit from CollegeCourse - include field that holds a lab fee - public function(s) setting the private field (don't forget the parent) - public function that displays a LabCourse's data (don't forget the parent) - main() function that instantiates a LabCourse, populates all private and inherited fields, calls both private and inherited methods
#include<iostream>
#include<string>
using namespace std;
class CollegeCourse {
private:
int courseNum;
string deptName;
int creditHours;
double tuitionDue;
public:
void setFields (int, string, int, double);
void displayData();
int getNum();
};
void CollegeCourse::setFields (int num, string dept, int credit,
double tuition) {
courseNum = num;
deptName = dept;
creditHours = credit;
tuitionDue = tuition;
}
void CollegeCourse::displayData() {
cout << "Course Number: " << courseNum << " Name:
" << deptName << endl;
cout << "Credit Hours: " << creditHours << "
Tuition Due: $ " << tuitionDue << endl;
}
class LabCourse : public CollegeCourse {
private:
int courseNum;
string deptName;
int creditHours;
double tuitionDue;
double labFee;
public:
void setFields (int num, string dept, int hours, double tuition,
double lab);
void displayData();
};
void LabCourse::setFields (int num, string dept, int hours, double
tuition, double lab) {
courseNum = num;
deptName = dept;
creditHours = hours;
tuitionDue = tuition;
labFee = lab;
}
void LabCourse::displayData(){
cout << "Course Number: " << courseNum << " Name:
" << deptName << endl;
cout << "Credit Hours: " << creditHours << "
Tuition Due: $ " << tuitionDue << endl;
cout << "Lab Fee: " << labFee << endl;
}
int main() {
CollegeCourse *obj = new CollegeCourse;
obj->setFields(101,"Physics",4,120.00);
obj->displayData();
delete obj;
cout << endl << endl;
LabCourse *obj2 = new LabCourse;
obj2->setFields(111,"Physics",4,120.00,45.00);
obj2->displayData();
delete obj2;
return 0;
}