Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TASK: Design a Student class template that has properties first name, last name, ID, four test scores, and associated weights. ----- Weighted average = weight1*T1

TASK: Design a Student class template that has properties first name, last name, ID, four test scores, and associated weights.

-----

Weighted average = weight1*T1 + weight2*T2 + weight3*T3 + weight4*T4

For Example: weightedAvg = 0.10(85.5) + 0.15(83) + 0.25(96) + 0.50(77) = 83.5

**The weights are always floats and you should make sure they add to 1 or 100%.

**The test scores could be of type int, float, or double. These should never be negative.

The class template should have a constructor, accessor methods, and a weighted average method. Also provide a straight scale grade method... A, B, C, D, or F.

-----

In the main, instantiate TWO student objects. Hard code the properties and demonstrate that your methods all work. No user interface.

//C++

//First question am I properly setting this up? and should I use Multiple Parameters instead

//Second question how do I align my draft to follow the prompt above

------

#include #include

using namespace std;

template class Student { public: //Default Constructor Student();

//Overload Construtor

Student(string, string, int, double, double, double, double, double, float, float, float, float, char);

//Destructor ~Student();

//Accessor Functions string getFirstName()const; string getLastName()const; int getID()const; float getWeight1()const; float getWeight2()const; float getWeight3()const; float getWeight4()const; double getTest1()const; double getTest2()const; double getTest3()const; double getTest4()const; double getWeightAverage()const; char getGrade()const;

//Mutator Functions void setFirstName(string); void setlastName(string); void setID(int); void setWeightAverage(double); void setGrade(char); void setTestScores(double,double,double,double); void setWeights(float, float, float, float);

private: //Member Variables string firstName,lastName; int ID; float weight1, weight2, weight3, weight4; double test1, test2, test3, test4, weightAverage; char grade;

};

int main(void) {

return 0; }

//Cons template Student::Student(string firstN, string lastN, int newID, double WeightAvg, float w1, float w2, float w3, float w4, double t1, double t2, double t3, double t4,char newGrade) { firstName = firstN; lastName = lastN; id = newID; weight1 = w1; weight2 = w2; weight3 = w3; weight4 = w4; weightAverage = weightAvg; test1 = t1; test2 = t2; test3 = t3; test4 = t4; grade = newGrade; };

template string Student ::getFirstName() const{ return firstName; }

template string Student ::getLastName()const { return lastName; }

template int Student ::getID()const { return id; }

template float Student ::getWeight1()const { return weight1; }

template float Student ::getWeight2()const { return weight2; }

template float Student ::getWeight3()const { return weight3; }

template float Student ::getWeight4()const { return weight4; }

template double Student ::getWeightAverage()const { return weightAverage; }

template double Student ::getTest1()const { return test1; }

template double Student ::getTest2()const { return test2; }

template double Student ::getTest3()const { return test3; }

template double Student ::getTest4()const { return test4; }

template char Student ::getGrade()const { return grade; }

template void Student::setFirstName(string firstN) { firstName = firstN; }

template void Student::setlastName(string lastN) { lastName = lastN; }

template void Student ::setID(int newID) { ID = newID; }

template void Student::setWeights(float w1, float w2, float w3, float w4) { weight1 = w1; weight2 = w2; weight3 = w3; weight4 = w4; }

template void Student ::setWeightAverage(double weightAvg) { weightAverage = weightAvg; }

template void Student::setTestScores(double t1, double t2, double t3, double t4) { test1 = t1; test2 = t2; test3 = t3; test4 = t4; }

template void Student ::setGrade(char Newgrade) { grade = newGrade; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions