-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentMarksheet.cpp
55 lines (48 loc) · 1.19 KB
/
StudentMarksheet.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
#include <iostream>
using namespace std;
class Student
{
private:
string name;
int rollNumber;
int marks[5];
int totalMarks;
float percentage;
public:
void inputDetails()
{
cout << "Enter student name : ";
getline(cin, name);
cout << "Enter roll number : ";
cin >> rollNumber;
cout << "Enter marks for 5 Subjects : \n";
totalMarks = 0;
for (int i = 0; i < 5; i++)
{
cout << "Subject " << i + 1 << ": ";
cin >> marks[i];
totalMarks += marks[i];
}
percentage = (float)totalMarks / 5;
}
void displayMarksheet()
{
cout << "\n-----Marksheet-----\n";
cout << "\nName : " << name << "\n";
cout << "Roll number : " << rollNumber << "\n";
cout << "\nMarks in subjects : \n";
for (int i = 0; i < 5; i++)
{
cout << "Subject " << i + 1 << ": " << marks[i] << "\n";
}
cout << "\nTotal marks : " << totalMarks << "\n";
cout << "Percentage : " << percentage << endl;
}
};
int main()
{
Student student;
student.inputDetails();
student.displayMarksheet();
return 0;
}