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
|
#pragma once
#include <iostream>
#include <string>
using namespace std;
class Student{
public:
int StudentID;
string Firstname;
string Lastname;
void PrintInfo();//this prints information about this student
Student(){Attendance=0; Final=0; Homework=0; Tests=0;}; //this is a default constructor. It does not do anything in this program. Normally, you should initialize your variables here
Student(int id, string lname,string fname,double attd,double fnl,double hmk,double tst);//this is another constructor (not the default, because it has parameters)
void SetAttendance(double grade);
double GetAttendance() const{ return Attendance;};
void SetFinal(double grade);
double GetFinal() const{ return Final;};
void SetHomework(double grade);
double GetHomework() const{ return Homework;};
void SetTests(double grade);
double GetTests() const{ return Tests;};
double GetGrade() const;
private:
double Homework; //scores from homework max 300 points - 30% of final grade
double Tests; // tests 100 max points - 30% of final grade
double Final; // final exam 100 max points - 30% of final grade
double Attendance; //attendance max 10 points - 10% of final grade
};
//We are going to implement the functions we defined in the Student class below
///use the values given to initialize the variables defined in the class
Student::Student(int id, string lname,string fname,double attd,double fnl,double hmk,double tst)
{
StudentID =id;
Firstname = fname;
Lastname = lname;
SetAttendance(attd);
SetFinal(fnl);
SetHomework(hmk);
SetTests(tst);
};
void Student::PrintInfo()
{
printf("ID=%d, Name:%s,%s\n\tAttendance: %2.2f\tTests:%2.2f\tHomework:%3.2f\tFinal:%3.2f\n\tFinal Grade:%3.2f\n--------------------------------\n",
StudentID,Lastname.c_str(),Firstname.c_str(),Attendance,Tests,Homework,Final,GetGrade());
};
// Calculate the final grade
double Student::GetGrade() const
{
//FILL IN THE CODES THAT COME HERE
};
//Attendance grade cannot be more than 10
void Student::SetAttendance(double grade)
{
//FILL IN THE CODES THAT COME HERE
};
//Final grade cannot be more than 100
void Student::SetFinal(double grade)
{
//FILL IN THE CODES THAT COME HERE
};
//Homework grade cannot be more than 300
void Student::SetHomework(double grade)
{
//FILL IN THE CODES THAT COME HERE
};
//Tests grade cannot be more than 100
void Student::SetTests(double grade)
{
//FILL IN THE CODES THAT COME HERE
};
|