Define a class in C++ called gradebook that can implement the following. The main will be calling this to pass in two different gradebooks.
class Gradebook
{
public:
// default constructor
Gradebook();
// return the size of the current vector: scores,
// which represents current gradebook
int getSize() const;
// insert a FinalGrade object, newFG,
// into the end of the current gradebook
void insert(FinalGrade newFG);
// return a FinalGrade object,
// which holds the maximum score in the current gradebook
FinalGrade getMax() const;
// return a FinalGrade object,
// which holds the minimum score in the current gradebook
FinalGrade getMin() const;
// return the average score among all scores in the current gradebook
double getAverage() const;
// For each FinalGrade object in the current gradebook,
// its score will be increased by the given value
// If the score reaches MAX_SCORE, it does not go beyond
void incrementScore(double value);
// print the FinalGrade objects in the current gradebook
void print() const;
private:
vector<FinalGrade> scores;
};
Since you have not provided the code for FinalGrade, I am assuming its definition and providing you the implementation.
CODE
class Gradebook
{
public:
Gradebook() {}
// return the size of the current vector: scores,
// which represents current gradebook
int getSize() const {
return scores.size();
}
// insert a FinalGrade object, newFG,
// into the end of the current gradebook
void insert(FinalGrade newFG) {
scores.push_back(newFG);
}
// return a FinalGrade object,
// which holds the maximum score in the current gradebook
FinalGrade getMax() const {
FinalGrade max = scores[0];
for (int i=1; i<scores.size(); i++) {
// here, I am assumign that FinalGrade has a method getScore()
if (scores[i].getScore() > max.getScore()) {
max = scores[i];
}
}
return max;
}
// return a FinalGrade object,
// which holds the minimum score in the current gradebook
FinalGrade getMin() const {
FinalGrade min = scores[0];
for (int i=1; i<scores.size(); i++) {
// here, I am assumign that FinalGrade has a method getScore()
if (scores[i].getScore() < min.getScore()) {
min = scores[i];
}
}
return min;
}
// return the average score among all scores in the current gradebook
double getAverage() const {
double avg = 0;
for (int i=1; i<scores.size(); i++) {
// here, I am assumign that FinalGrade has a method getScore()
avg += scores[i].getScore();
}
return avg / (double)(scores.size());
}
// For each FinalGrade object in the current gradebook,
// its score will be increased by the given value
// If the score reaches MAX_SCORE, it does not go beyond
void incrementScore(double value) {
for (int i=1; i<scores.size(); i++) {
// here, I am assumign that FinalGrade has methods getScore() and setScore()
scores[i].setScore(scores[i].getScore() + value);
}
}
// print the FinalGrade objects in the current gradebook
void print() const {
for (int i=1; i<scores.size(); i++) {
// here, I am assumign that FinalGrade has a method getScore()
cout << scores[i].getScore() << endl;
}
}
private:
vector<FinalGrade> scores;
};
Define a class in C++ called gradebook that can implement the following. The main will be...
2 Class Vec Message1 2.1 Introduction • Write a class Vec Message1 with the following declaration. class Vec_Message1 { public: Vec_Message1(); Vec_Message1(int n); Vec_Message1(int n, const Message1 &a); Vec_Message1(const Vec_Message1 &orig); Vec_Message1& operator= (const Vec_Message1 &rhs); ~Vec_Message1(); int capacity() const; int size() const; Message1 front() const; Message1 back() const; void clear(); void pop_back(); void push_back(const Message1 &a); Message1& at(int n); private: void allocate(); void release(); int _capacity; int _size; Message1 * _vec; }; 2.2 allocate() and release() • Examine the...
C++ implement and use the methods for a class called Seller that represents information about a salesperson. The Seller class Use the following class definition: class Seller { public: Seller(); Seller( const char [], const char[], const char [], double ); void print(); void setFirstName( const char [] ); void setLastName( const char [] ); void setID( const char [] ); void setSalesTotal( double ); double getSalesTotal(); private: char firstName[20]; char lastName[30]; char ID[7]; double salesTotal; }; Data Members The...
implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...
For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...
Create this c++ program. Create to classes and name their type
Account and Money. Follow the instruction listed below. Please read
and implement instructions very carefully
Money Class Requirements - Negative amounts of Money shall be stored by making both the dollars and cents negative The Money class shall have 4 constructors * A default constructor that initializes your Money object to $0.00 A constructor that takes two integers, the first for the dollars and the second for the cents...
Create a BoxFigure class that inherits RectangleFigure class BoxFigure Class should contain:- Height instance field- Default constructor -- that calls the default super class constructor and sets the default height to 0- Overloaded constructor with three parameters (length, width and height) – that calls the two parameterized super class constructor passing in length and width passed and sets the height to passed height.- setDimension method with three parameters (length, width, height) – call the super class setDimension and pass in...
Pure Abstract Base Class Project. Define a class called BasicShape which will be a pure abstract class. The class will have one protected data member that will be a double called area. It will provide a function called getArea which should return the value of the data member area. It will also provide a function called calcArea which must be a pure virtual function. Define a class called Circle. It should be a derived class of the BasicShape class. This...
Code should be in C# Create a class called SavingsAccount. Use a static variable called annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance. Provide static method setAnnualInterestRate to set the annualInterestRate to a new value....
c++
Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...
implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...