Hello all,
For this program (assignment), the user enters the names of five students, and their respective four test scores. The program will then average the scores, and display them for the user.
Part of the requirement for the program is that we use five single-dimensional arrays of 'doubles' to store the sets of test scores (I'm sure a two-dimensional array would be easier, but again, a requirement for the assignment).
Where I'm stuck is how I can use a loop (with cin) to store the data entered by the user into the separate arrays. So far, the program will store the test scores in the first array, but that's it.
This is my first programming class, so please be gentle ;-)
Thanks!
vandadm
#include <iostream>
using namespace std;
int main()
{
const int STUDENT_NAME = 5; //number of names
const int NUM_SCORES = 4; //number of scores entered by user
const int STRING_SIZE = 15; //maximum numer of characters
char names[STUDENT_NAME][STRING_SIZE]; //array for the names of the students
char letter_grade[5]; //array for the letter grade
double score1[NUM_SCORES],
score2[NUM_SCORES],
score3[NUM_SCORES],
score4[NUM_SCORES];
double average;
//Loop that will get the name of the student, test scores, and average them.
for (int index = 0; index < STUDENT_NAME; index++)
{
cout << "Enter the name of student " << (index + 1) << " : ";
cin >> names[index];
cout << "Enter the test scores for " << names[index] << ":" << endl;
for (index = 0; index < NUM_SCORES; index++)
{
cin >> score1[index];
}
}
return 0;
}