here is my problem:
write a class that finds the average of an array of 5 test scores. Those scores are 98,73, 65, 41, and 89. The class should have varaibles needed to hold the array and the average. The class should also have one constructor and one function that finds the average.
im a noob at c++ can someone help me with this?
thank you
well i understand classes and arrays and such, i just need a little help getting started.
is this how it should go?:
# include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int scoresArray = 5
int scores[scoresArray] {98, 73, 65, 41, 89};
cout << "this program will average the test scores already stored in an array. \n" endl;
i am a little fuzzy on where to use classes in this program
also would it help to use any loops?
i am continuing writing more code for it this is just to see if i am starting it correctly.
Hmm. I see no classes in there. You'll need to define a class just above main() with your int[5], a separate int, a function for returning an average, a default constructor, and make an instance of it classname instancename; in main().
Now you need to get the vast majority of that into a class (why didn't you do this from the start?). Are you sure you know how to? Asking doesn't hurt around here!
i just realized that lmao, thank you for the help so far,
so in the private class i should have defined variables and in the public i need all the functions correct?
The default constructor should look something like that you have there, yes.
As for the variables, it's good practice to have the variables private and all the functions you need public. It might be a good idea to provide some sort of access to the average variable (remember, you want to only be able to access its value, not set it) and the array (you need to set its value somehow). Although, if you want to be able to access the array's value, then you might as well make it public. :)