Hi,
I am new to array and classes,
I am working on a homework assignment and have come to a bit of a stand still
We are to add scores through an addScore object and then have the program sort the biggest and smallest scores. MAX_SIZE constant is to be 100. The professor gave us the numbers to put in our arrays and what number we should get once the arrays have been passed through the find biggest and smallest functions
I was able to find some examples in the book and build a good start of the coding for the grader.h and grader driver.cpp
but I am having trouble figuring out what to program into the grader.cpp-- specifically where to start with the addScores objects
below is the code I have so far
grader.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#ifndef GRADER_H
#define GRADER_H
#include <iostream>
#include <cstdlib>
usingnamespace std;
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;
In the first snippet it looks like you wanted to write a class def, but you didn't write it out correctly.
In the second snippet you write expressions outside of a function, this is not allowed in C++. You must write that code (except for the #includes, probably) inside a function, such as main.
#include "grade.h"
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main {
Grader( );
void addScore( int score );
void addScores( int scores[],
int size );
void clear();
int findBiggest( ) const;
int biggest;
if (scores > 0) {
biggest = scores[0];
for (int i = 1; i < scores; i++)
if (scores[i] > biggest)
biggest = scores[i];
}
return biggest;
}
int findSmallest( ) const;
int my_Values[ MAXSIZE ];
int my_valuesSeenSoFar;
}