-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq12.cpp
62 lines (54 loc) · 1.22 KB
/
q12.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
54
55
56
57
58
59
60
61
62
/*WAP using the concept of class and object.
* Define student class
* Data members:
* -enroll no
* -Name
* -float marks[5]
* - floart perc
* Member function:
* -input()
* -calculateper()
* -output()
*/
#include <iostream>
#define SUBJECT_MAX_MARKS 100.0
using namespace std;
class Student {
public:
string enroll_no, name;
float marks[5], perc;
int input();
int calculatePerc();
int output();
};
int Student::input() {
cout << "Enter marks of 5 subjects: " << endl;
for (int i = 0; i < 5; i++) {
cout << "Enter marks of subject " << i + 1 << ": ";
cin >> marks[i];
}
return 0;
}
int Student::output() {
cout << "Percentage : " << perc << endl;
return 0;
}
int Student::calculatePerc() {
perc = 0;
for (int i = 0; i < 5; i++) {
perc += marks[i];
}
perc = (perc / (5 * SUBJECT_MAX_MARKS)) * 100.0;
return 0;
}
int main() {
Student bca[2];
for (int i = 0; i < 2; i++) {
cout << "============ STUDENT " << i + 1<< "============" << endl;
bca[i].input();
bca[i].calculatePerc();
bca[i].output();
cout << endl;
}
return 0;
}