arrays and loops

Hello. I am given 'n' names of students, then 'k' amount of tasks they've got marks for. Each task has its own coefficient(e.g. if there are 4 tasks, there are 4 coefficients: 0.2; 0.3; 0.3; 0.4), so the amount of coefficients is also 'k'. My job is to
1. Read 'n'(the amount of students) and 'k' (amount of tasks)
2. Read all of the coefficients(that I will have to multiply with each mark of each student later)
3.Read the specific name and the 'k' amount of marks each student got and,as I've said, multiply each mark with the coefficient. Coefficients are static. After doing that, I have to sum all of the 4 multiplications I have done for 1 student and it will be his final grade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;
int main(){

    int n, k, b = 0;
    double coefficients[10], marks[10], final[30] = {0};
    string name, names[30];

    cin >> n >> k;               //reading the amount of students n tasks
    for(int i = 0; i < k; i++){  //reading coefficients
        cin >> coefficient[i];
    }

    for(int i = 0; i < n; i++){    //reading names
      cin.ignore(80, '\n');
      getline(cin,name);
      names[i] = name;
      for (int j = b; j < k; j++){   //reading marks
        cin >> marks[j];
        marks[j] *= coefficient[j];   // trying to get the final mark for each students
        finalmark[j] += marks[j];
      }
      b += k;
      k += k;
    }




How do I assign finamark[0] for name[0] and so on? I have trouble getting the final mark
Last edited on
Topic archived. No new replies allowed.