Working on an assignment to practice with arrays and calculate a users grade but am stuck on the initializing for loop on line 54. Don't really know what to put in it. After I get this I can start working on the arithmetic of grade percent. But really need to finish the loop before that. Any advice would be appreciated.
#include <iostream>
#include "CinReader.h"
usingnamespace std;
CinReader reader;
void print (int numberArray, int sizeOfNumberArray);
void initialize (int numberArray, int sizeOfNumberArray);
int main()
{
int *gradesEarned;
int *gradesPossible;
int totalGrades = 0;
cout << "You can find your grade for up to ten assignments. " << endl << "How many would you like to grade: ";
totalGrades = reader.readInt(1,10);
cout << "\n";
cout << "Ok, you would like to grade " << totalGrades << " assignments\n\n";
gradesEarned = newint[totalGrades];
gradesPossible = newint[totalGrades];
initialize(gradesEarned, totalGrades);
initialize(gradesPossible, totalGrades);
print(gradesEarned, totalGrades);
print(gradesPossible, totalGrades);
delete [] gradesEarned;
delete [] gradesPossible;
return 0;
}
void initialize (int numberArray[], int sizeOfNumberArray)
{
// Asking Amount of Points earned and possible -------------------------------------------------------
cout << "How many points did you earn on the assignment: ";
numberArray = reader.readInt(1,100);
cout << "\n";
cout << "Ok you earned " << numberArray << " points on this assignment \n\n";
cout << "How many points were possible on the assignment: ";
sizeOfNumberArray = reader.readInt(1,100);
cout << "\n";
cout << "Ok there were " << sizeOfNumberArray << " possible on this assignment: ";
for (int i
}
void print (int numberArray[], int sizeOfNumberArray)
{
for (int i = 0; i<sizeOfNumberArray; i++)
cout << numberArray[i] << " __ ";
cout << endl;
}
Well it isn't too difficult. You already made a for loop in the print function. You obviously know how to extract data from an array. Are you just trying to have the user enter totalGrades number of grades? If so pass both arrays and one size into initialize and loop that many times.
Here is something that you might want to read in case you want to use C++ dynamic sequence containers. It'll save you the trouble of worrying about memory leaks. http://cplusplus.com/forum/articles/20881/