-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut45.cpp
91 lines (84 loc) · 1.84 KB
/
tut45.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
using namespace std;
class Student
{
protected:
int roll_no;
public:
void set_number(int r)
{
roll_no = r;
}
void print_number()
{
cout << "Your roll number is : " << roll_no << endl;
}
};
class Test : virtual public Student
{
protected:
float maths;
float physics;
float chemistry;
float english;
float computer_science;
public:
void set_marks(float m, float p, float c, float e, float cs)
{
maths = m;
physics = p;
chemistry = c;
english = e;
computer_science = cs;
}
void print_marks()
{
cout << "Your maths marks is :" << maths << endl;
cout << "Your physics marks is : " << physics << endl;
cout << "Your chemistry marks is : " << chemistry << endl;
cout << "Your english marks is : " << english << endl;
cout << "Your computer science marks is : " << computer_science << endl;
}
void percent_marks()
{
cout << "Your percentage is :" << (maths + physics + chemistry + english + computer_science) / 5 << endl;
}
};
class Sports : virtual public Student
{
protected:
int score;
public:
void set_score(int s)
{
score = s;
}
void print_score()
{
cout << "Your Physical training score is :" << score << endl;
}
};
class result : public Test, public Sports
{
protected:
float total;
public:
void display()
{
total = maths + physics + chemistry + english + computer_science + score;
print_number();
print_marks();
percent_marks();
print_score();
cout << "Your total marks is : " << total << endl;
}
};
int main()
{
result ritik;
ritik.set_number(7);
ritik.set_marks(81, 94, 76, 75, 82);
ritik.set_score(7);
ritik.display();
return 0;
}