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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
#include <iostream>
#include <string>
#include <ifstream>
using namespace std;
struct course
{
string code, title;
int credit, mark;
};
class Student
{
public:
void print() const;
set (string, float, int);
getGPA (float&);
getnumberOfCourses(int)const;
calculateGPA(float);
student (string, float, int);
private:
string ID, name;
float GPA;
int numberOfCourses;
array coursesTaken[10];
};
#include "student.h"
class TA: public student
{
public:
void print() const;
void set(Student, Student, Student);
void get(Student&, Student&, Student&) const;
TA (Student, Student, Student);
private:
string department;
float rating, salary;
int numberOfHours;
};
#include "student.h"
int main()
{
TA someTA;
char TAName[50];
int nCourses, nHours;
string sID, dept;
float pRate;
inFile >> nCourses >> sID;
inFile.getline(TAName, 50);
cout << "Enter the department name: ";
cin >> dept;
cout << "Enter the number of hours: ";
cin >> nHours;
cout << "Enter the rating: ";
cin >> pRate;
someTA.set(inFile, sID, TAName, nCourses, dept, nHours, pRate);
someTA.print();
return 0;
}
#include "student.h"
void student::set(inFile, sID, nCourses)
{
inFile = courses;
sID = ID; // studentId
nCourses = numberOfCourses;
}
void getGPA(float G, int nCourses)const
{
if (G >=3 && nCourses <5);
}
void Student::calculateGPA(float);
{
float N,x=0,nCourses=0,gpa;
for(int i=0;i<numberOfCourses;i++)
{
N = Array[i].mark;
if(0<=N&&N<60)
gpa=0;
else if(60<=N&&N<65)
gpa=1;
else if(65<=N&&N<70)
gpa=1.5;
else if(70<=N&&N<75)
gpa=2;
else if(75<=N&&N<80)
gpa=2.5;
else if(80<=N&&N<85)
gpa=3;
else if(85<=N&&N<90)
gpa=3.5;
else
gpa=4;
nCourses=Array[10].m+nCourses;
nT=nT+Array[10].m*gpa;
}
GPA=nT/nc
}
void print ()const
{
cout<<id<<" "<<name<<"has GPA = "<<GPA;
}
#include "TA.h"
void TA::print() const
{
cout<<id<<" "<<name<<"has GPA = "<<GPA;
}
void TA::set(string dept, int nHours, float pRate)
{
department=dept;
numberOfHours=nHours;
rating=pRate;
}
void TA::get(department, numberOfHours, rating) const
{
dept= department;
nHours=numberOfHours;
pRate= rating;
}
TA::salary(float rate, float sal, int nHours)
{
salary = rating * nHours
if (nOfHours <= 40)
else 1.5++
return salary;
}
|