WriIn your program you are going to save 3 exam grades (Exam 1, Exam 2 and Exam 3) of 5 students in a 2D array. First create an array of strings of size 5 called studentNames[]like Assignment 39.
const int numStudents = 5; // holds Number of students
string studentName[numStudents] = { "Amanda Baynes" , "Victor Hughes" , "Scott Collins", "Lori Macbeth", "Manny Lopez" }; // holds Name of students
Then create an array of integers of 5 rows and 3 columns of integers called studentGrades[][].
const int NUM_Rows = 5, NUM_Cols = 3;//number of rows and columns
double studentGrade[NUM_Rows][NUM_Cols];
Each row of this array will contain the exam grades for each student. That is, Amanda’s exam 1, exam 2 and exam 3 grades will be contained in studentGrades[0][0], studentGrades[0][1] and studentGrades[0][2] respectively.
Initialize studentNames[] in the program , and ask the user for the grades of each student
In nested for loops, print the names of the students, along with their grades.
it should look like this
Enter Exam 1 score for Amanda Baynes: 89
Enter Exam 2 score for Amanda Baynes: 80
Enter Exam 3 score for Amanda Baynes: 95
Enter Exam 1 score for Victor Hughes: 67
Enter Exam 2 score for Victor Hughes: 78
Enter Exam 3 score for Victor Hughes: 80
Enter Exam 1 score for Scott Collins: 91
Enter Exam 2 score for Scott Collins: 94
Enter Exam 3 score for Scott Collins: 89
Enter Exam 1 score for Lori Macbeth: 65
Enter Exam 2 score for Lori Macbeth: 70
Enter Exam 3 score for Lori Macbeth: 78
Enter Exam 1 score for Manny Lopez: 78
Enter Exam 2 score for Manny Lopez: 80
Enter Exam 3 score for Manny Lopez: 85
Student name Exam 1 Exam 2 Exam 3
------------------------------------
Amanda Baynes 89 80 95
Victor Hughes 67 78 80
Scott Collins 91 94 89
Lori Macbeth 65 70 78
Manny Lopez 78 80 85
this is what i have
const int numStudents = 5; // holds Number of students
string studentName[numStudents] = { "Amanda Baynes" , "Victor Hughes" , "Scott Collins", "Lori Macbeth", "Manny Lopez" }; // holds Name of students
const int Num_Exam = 0;
const int NUM_Rows = 5, NUM_Cols = 3;//number of rows and columns
double studentGrade[NUM_Rows][NUM_Cols];
int exam;
for (int count = 0; count < numStudents; count++)
{
for (exam=0;exam <numStudents; exam++)
cout << " Enter Exam " << Num_Exam + 1 << " for " << studentName << endl;
}
system("pause");
return 0;
}
I'M lost and it is doing something weird
UPDATE!!! This is now what i have and it is looking some what better.
#include<iostream>
#include<string>
using namespace std;
int main()
{
const int num_Students = 5; // Number of students
const int num_Scores = 3; // Number of Exam Scores
string studentName[num_Students] = { "Amanda Baynes" , "Victor Hughes" , "Scott Collins", "Lori Macbeth", "Manny Lopez" }; // Name of students
int studentGrade[num_Students]; //Student Grade
It looks like you are close to done. The only thing you have left to do is the print the data from the arrays. This should be simple for you given the work you have already shown. Visualize the data in your two dimensional array as being stored in rows and columns. We will print each students name and then the data stored in each column of that row.
This can easily be done by nesting loops. The outer loop will traverse the rows of the array moving down the y-axis. The inner loop will traverse the columns of a row moving along the x-axis. The code statement in the inner loop will be responsible for printing the data from the array to the console. The outer loop will be responsible for moving the column to the next line.
1 2 3 4 5 6 7 8 9
for(int y = 0; y < row; y++)
{
print name y
for(int x = 0; x < col; x++)
{
print data x
}
move to next line
}