Good afternoon coders!
We recently starting learning about derivied classes and I am having trouble with the objects and printing out information from other classes.
*********
This is the instruction we have to do and I am having problems with the print() and findSalary() functions:
1)in the main program:
a. Create an object of Adjunct professor
b. Set the name to “Adam Smith”, facultyId to12345, email to “asmith@csusm.edu”, degree to “Master degree”. Adam Smith is teaching 1 course and is doing teaching assistant (TA) for two courses.
c. Call the findSalary() method to find the salary of Adam Smith
d. Print Adam Smith’s information (properties) on the screen
**********
This is the Salaries calculation:
The salary of an adjunct professor is calculated as follows:
Salary = The amount of money earned from doing TA + The amount of money earned from teaching courses
|Degree| |Salary for one TA | |Salary for teaching one course|
Bachelor $1500 $3000
Master $2000 $4000
PhD $2500 $5000
For example, if an adjunct professor has a master degree and doing 2 TA and teaching 3 courses, he/she earns (2*$2000)+(3*$4000) = $16000
All of my codes compile but I just don't know where to go from here. I know this might be easy to a lot of you advanced coders but I am still learning and although I enjoy coding and find it fun, I get really frustrated at times. Thank you!
Here is my code:
CompSciProfessor:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#ifndef COMPSCIPROFESSOR_H
#define COMPSCIPROFESSOR_H
#include <iostream>
#include <string>
using namespace std;
class CompSciProfessor
{
private:
string name, email;
long facultyId;
public:
CompSciProfessor()
{
name= " ";
email = " ";
facultyId= 0.0;
}
CompSciProfessor(string n, string e, long f)
{
name=n;
email=e;
facultyId=f;
}
string getName() const
{
return name;
}
string getEmail() const
{
return email;
}
long getId() const
{
return facultyId;
}
};
#endif
|
AdjunctProf.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#ifndef ADJUNCTPROF_H
#define ADJUNCTPROF_H
#include "CompSciProfessor.h"
#include <iostream>
#include <string>
using namespace std;
class AdjunctProf : public CompSciProfessor
{
private:
char degree;
int NoOfTA;
int NoOfCourses;
public:
//constructor
AdjunctProf(): CompSciProfessor()
{
degree= ' ';
NoOfTA=0;
NoOfCourses=0;
}
//constructor #2
AdjunctProf( string n, string e, long f, char d, int TA, int Courses) : CompSciProfe\
ssor(n, e,f )
{
degree=d;
NoOfTA=TA;
NoOfCourses=Courses;
}
//mutators
void setDegree(char d)
{
degree=d;
}
void setTA(int TA)
{
NoOfTA=TA;
}
void setCourses(int Courses)
{
NoOfCourses=Courses;
}
//Accessor
char getDegree()const
{
return degree;
}
int getTA()const
{
return NoOfTA;
}
int getCourses() const
{
return NoOfCourses;
}
void print() const
{
}
float findSalary() const
{
}
};
#endif
|
TenuretrackProf.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#ifndef TENURETRACKPROF_H
#define TENURETRACKPROF_H
#include "CompSciProfessor.h"
using namespace std;
class TenureTrackProf : CompSciProfessor
{
private:
char rank;
int YearOfExp;
public:
//Default constructor
TenureTrackProf() : CompSciProfessor()
{
rank= ' ';
YearOfExp=0;
}
//constructor #2
TenureTrackProf(string n, string e, long f, char r, int y) : CompSciProfessor( n, e,\
f)
{
rank=r;
YearOfExp=y;
}
//accesors
char getRank() const
{
return rank;
}
int getYear() const
{
return YearOfExp;
}
void print() const
{
}
float findSalary() const
{
}
};
#endif
|
My Main:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <iomanip>
#include "CompSciProfessor.h"
#include "AdjunctProf.h"
#include "TenureTrackProf.h"
using namespace std;
int main()
{
AdjunctProf A("Adam Smith", "asmith@csusm.edu", 12345, 'M' ,2, 1);
return 0;
}
|