-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2dArrayTask2.cpp
53 lines (46 loc) · 1.33 KB
/
2dArrayTask2.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;
int main()
{
//1. First we will get students' multiple subjects marks
// and display them
//2. Then we will calculate each subject gpa
const int STUDENTS = 2;
const int SUBJECTS = 3;
int marks[STUDENTS][SUBJECTS];
float subGpa[STUDENTS][SUBJECTS];
for(int i=0; i<STUDENTS; i++)
{
cout<<"**************************************\n";
cout<<"\tStudent "<<i+1<<endl;
cout<<"**************************************\n";
for(int j=0; j<SUBJECTS; j++)
{
cout<<"Enter marks for subject "<<j+1<<" : ";
cin>>marks[i][j];
}
}
for(int i=0; i<STUDENTS; i++)
{
cout<<"**************************************\n";
cout<<"\tStudent "<<i+1<<endl;
cout<<"**************************************\n";
for(int j=0; j<SUBJECTS; j++)
{
if(marks[i][j] >= 87 && marks[i][j] <= 100)
subGpa[i][j] = 4.0;
else if(marks[i][j] >= 80 && marks[i][j] < 87)
subGpa[i][j] = 3.5;
else if(marks[i][j] >= 72 && marks[i][j] < 80)
subGpa[i][j] = 3.0;
else if(marks[i][j] >= 67 && marks[i][j] < 72)
subGpa[i][j] = 2.5;
else if(marks[i][j] >= 60 && marks[i][j] < 67)
subGpa[i][j] = 2.0;
else
subGpa[i][j] = 0.0;
cout<<"Subject "<<j+1<<"\t"<<"Marks = "<<marks[i][j]<<"\tGPA = "<<subGpa[i][j]<<endl;
}
}
return 0;
}