Arrays and grade averages

???

Write a C++ program that can be used to determine grades at the end of the semester. For each student, who is identified by an integer number between 1 and 60, four examination grades must be kept. Additionally, two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: the first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade a weight of 0.3, an the fourth grade a weight of 0.2; that is computed as:

0.3*grade1 + 0.2*grade2 + 0.2*grade3 + 0.3*grade4

Using this info, you are to construct a 60X7 two dimensional array, in which the first column used for the student number, the next four columns for the grades, and the last two columns for the computed final grades. The output of the program should be a display of the data in the completed array.

write the program?
Write!:)
I doubt anyone is just going to write the program and do your work for you. However if you have questions, I am sure that there would be plenty of qualified people willing to offer their expertise.
@BranL


Is English your native language?
¿too good?
@ne555

¿too good?


Comparing with my awful English it is indeed too good.:)
I've got this so far. I just don't understand how to print the array out and then how to find the average on the last two rows?? :/

#include <iostream>
#include <iomanip>
using namespace std;
void printarray (int [ ][5]);
int main ( )
{

cout << "Student" << setw(12) << "Grade 1"<< setw(15) << "Grade 2"<< setw(15)<<"Grade 3"<< setw(15)<< "Grade 4"<< setw(15)<< "Average 1"<< setw(15)<<"Average 2"<<endl;

int array1 [5] [5] = { {1, 100, 100, 100, 100}, {2, 100, 0, 100, 0},{3, 82, 94, 73, 86},{4, 64, 74, 84, 94},{5, 94, 84, 74, 64}};
cout<<printarray (array1);

return 0;
}
void printarray (int a[ ] [5] )
{
for(int c=0; c<5; c++)
cout<<a;
}



@vlad from moscow

Yes it is.

@virginiababy

A regular average is defined as the sum of the numbers divided by the number of numbers. So, in your first entry for the array, {1, 100, 100, 100, 100}, the average would be, (100 + 100 + 100 + 100) / 4, which would equate to 100.

For a weighted average, you take the sum of each score multiplied by its weight. So, again using your first example, the weights as given are 20%, 30%, 30%, and 20% for each score. WA = .2*100 + .3*100 + .3*100 + .2*100.

In the code it could be array1[1][5] = (array[1][1] + array[1][2] + array[1][3] + array[1][4]) / 4 for the regular average

And array1[1][6] = array[1][1] * .2 + array[1][2] * .3 + array[1][2] * .3 + array[1][4] * .2 for the weighted, both of these could be put into a for loop for (int i = 0; i < 60; i++) {replace first 1 above, with i here}


As for printing out the array, you are on the write track with your printarray funtion; you would not need to call it as cout << printarray, just printarray(array1) would work.
If you replace the cout << a with an extra for loop
1
2
3
4
5
6
7
8
for(int c=0; c < 60; c++)
{
  for (int r = 0; r < 7; r++)
  {
     cout << a[c][r] << "\t"; // "\t" adds a tab between each value on the line
  }
  cout << "\n";
}


I am not very good at explaining myself sometimes, so if you have any questions about the above, just let me know.
Thank you sooooo much, and I will!
Topic archived. No new replies allowed.