First, complete everything that is required of you at the top of the file. Then complete the code wherever it says, "Write your code here ..." according to the comment lines above that line. Test your code using the following input from the keyboard Quiz#1, 3, 3, 1O Quiz#2, 3, 2, 13.5 Quiz#3, 2, 1, 14.5 The expected output can be found at the bottom of the given source file, also shown below. List of quiz activities: Course Activity: Quiz#1 Attempts Available: 3 Attempts Taken: 3 Score: 10.0 Course Activity: Quiz#2 Attempts Available: 3 Attempts Taken: 2 Score: 13.5 Course Activity: Quiz#3 Attempts Available: 2 Attempts Taken: 1 Score: 14.5
PLEASE. use it as a template
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
using namespace std;
//******************************************************************************
// This is the base class for all course activities.
// Do not change it.
//******************************************************************************
class CourseActivity {
private:
string name;
public:
CourseActivity(string aname): name(aname) {}
string getName() const { return name; }
void setName(string aname) { name = aname; }
void report() const {
cout << "Course Activity: " << name << endl;
}
};
// A declaration of the QuizAssignment class which you'll provide its
// full definition below. Once you have written the class, you can delete
// this line.
class QuizActivity;
//******************************************************************************
// Create a public derived class from CourseActivity named QuizActivity
// with three more member variables for storing the available number of
// attempts, attempts taken, and score.
// Use int for the available number of attempts and attempts taken.
// Use double for the score.
// You need to provide the default constructor and a parameterized constructor.
// You need to provide the accessor and mutator functions for the new
// data members.
// You need to redefine the report member function so that it can print
// the activity name, the available number of attempts, the attempts taken
// and the score.
//******************************************************************************
// Write your code here . . .
// Prototype of the reportQuizActivities function
void reportQuizActivities(const QuizActivity *ptr, int size);
int main() {
// Dynamically create an array of QuizActivity objects using
// the number entered from keyboard.
//
// You can assume the first line of input is a number that tells
// you how big the array should be. Use new to dynamically
// create the array.
// Write your code here . . .
// For each QuizActivity object, set its data members using the
// data extracted from the line of user input.
// Each input line contains comma separated data for
// a lab assignment. For example, a line may look like this.
// Quiz#1, 3, 1, 14.5
// Write your code here . . .
// Call reportGradedAssignments function to print a report of the lab
// assignments
// Write your code here . . .
// Delete the allocated array and reset the pointer
// Write your code here . . .
return 0;
}
//******************************************************************************
//* Function Name: reportQuizActivities
//* Description: This function does a report of the quiz activities from
//* the array of QuizActivity objects it receives.
//*
//* Parameters:
//* ptr - pointer to the first QuizActivity object in the array
//* size - size of the array
//*
//* Return:
//* None
//******************************************************************************
// Write your code here . . .
/*
Use the following lines to test your program:
3
Quiz#1, 3, 3, 10
Quiz#2, 3, 2, 13.5
Quiz#3, 2, 1, 14.5
*/
/*
Here is what the output looks with the test input.
List of quiz activities:
Course Activity: Quiz#1
Attempts Available: 3
Attempts Taken: 3
Score: 10.0
Course Activity: Quiz#2
Attempts Available: 3
Attempts Taken: 2
Score: 13.5
Course Activity: Quiz#3
Attempts Available: 2
Attempts Taken: 1
Score: 14.5
*/
Trending now
This is a popular solution!
Step by step
Solved in 2 steps