Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++. Arrays - Grader The purpose of this assignment is to practice dealing with arrays and array parameters. Arrays are neither classes nor objects. As

C++.

Arrays - Grader

The purpose of this assignment is to practice dealing with arrays and array parameters. Arrays are neither classes nor objects. As a result, they have their own way of being passed as a parameter and they also do not support the dot operator (.), so you cannot determine how full they are. This results in some pain and suffering when coding with arrays. It is this awareness that I am trying to get across to you in this homework assignment.

Grader

The Grader class is keeping track of a set of exam scores. Scores can be added one at a time thru calls toaddScore(...)or it can add a set of scores thru calls toaddScores(...). Once scores have been collected, the Grader class can find the best and worst scores it has seen so far thru calls tofindBiggest()andfindSmallest().

  • findBiggest()returns the value of the largest score in the grader. If no scores are present, return -1.
  • findSmallest()returns the value of the smallest score in the grader. If no scores are present, return -1.

Both of these methods are read-only operations, so you won't be able to change or update anything inside the Grader instance object. Processing arrays lead to lots of loops and that is what will be necessary in these methods. As for theMAX_SIZEconstant, I would recommend you just set it to a very large number (say 100...) and move on.

You will notice also that the class Grader has an integer counter namedvaluesSeenSoFar. This counter is meant to tell you how full the array actually is. Since an array is not a class, you can't ask themy_Valuesarray any questions. This counter needs to be maintained (incremented and decremented) by your Grader class code, as driver code fills and empties the array.

Following the class diagrams shown below, implement the Grader class. Embed your class in a suitable test program that proves your calculations are correct. You may choose to becreated any number of additional methods, but you are required to implement all of the public methods shown below. You are free to ignore the private parts of the class I suggest below.

Implementation Details - Grader

Grader(); void addScore(int score); void addScores(int scores[], int size); void clear(); int findBiggest() const; int findSmallest() const; int my_Values[MAXSIZE]; int my_valuesSeenSoFar; 

Sample Driver Code

Grader g; int d[5]= {99,70,85,93,84}; int e[4]= {100,81,60,91}; g.addScore(75); g.addScore(82); g.addScores(d, 5); cout << "Best Score = " << g.findBiggest() << endl; /// should give value 99 cout << "Worst Score = " << g.findSmallest() << endl; /// should give value 70 g.clear(); g.addScore(50); g.addScore(74); g.addScores(e, 4); cout << "Best Score = " << g.findBiggest() << endl; /// should give value 100 cout << "Worst Score = " << g.findSmallest() << endl; /// should give value 50 

Sample Output

Best Score = 99 Worst Score = 70 Best Score = 100 Worst Score = 50 

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

Step: 3

blur-text-image

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

What is operatiing system?

Answered: 1 week ago