Repository navigation
Expand file tree
/
Copy pathAss1_StudentDatabase.cpp
More file actions
151 lines (126 loc) · 2.15 KB
/
Copy pathAss1_StudentDatabase.cpp
File metadata and controls
151 lines (126 loc) · 2.15 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include<iostream>
using namespace std;
class Student
{
public:
int roll[100],n,marks[100];
char attendance[100];
public:
void get_data()
{
cout<<"\nEnter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
roll[i]=i+1;
cout<<"\nEnter the attendence for roll no."<<roll[i]<<" ";
cin>>attendance[i];
if(attendance[i]=='p')
{
cout<<"\nEnter the marks for roll no."<<roll[i]<<": ";
cin>>marks[i];
}
else
{
marks[i]=-1;
}
}
}
void display_data()
{
cout<<"\n\n*********ALL STUDENTS*********";
cout<<"\nRoll No.\tAttendance\tMarks";
for(int i=0;i<n;i++)
{
cout<<"\n"<<roll[i]<<"\t\t"<<attendance[i]<<"\t\t"<<marks[i];
}
}
void average()
{
int present=0;
int total=0;
float average;
for(int i=0;i<n;i++)
{
if(attendance[i]=='p')
{
present++;
total=total+marks[i];
}
}
cout<<"\n\n*********AVERAGE*********";
cout<<"\nPresent Students are: "<<present;
average=total/present;
cout<<"\nAVERAGE MARKS: "<<average;
}
void max_min()
{
int max=0;
int min=99;
for(int i=0;i<n;i++)
{
if(attendance[i]=='p')
{
if(marks[i]>max)
{
max=marks[i];
}
if(marks[i]<min)
{
min=marks[i];
}
}
}
cout<<"\n\n*********MAX AND MIN*********";
cout<<"\nMAX is: "<<max;
cout<<"\nMIN is: "<<min;
}
void display_absent()
{
cout<<"\n\n*********ABSENT STUDENTS*********";
cout<<"\nRoll No.\tAttendance\tMarks";
for(int i=0;i<n;i++)
{
if(attendance[i]=='a')
{
cout<<"\n"<<roll[i]<<"\t\t"<<attendance[i]<<"\t\t"<<marks[i];
}
}
}
void most_marks()
{
int arr[10];
int m=0;
int k=0;
for(int i=0;i<10;i++)
{
arr[i]=0;
}
for(int i=0;i<n;i++)
{
int temp=marks[i]/10;
arr[temp]++;
}
for(int i=0;i<10;i++)
{
if(arr[i]>m)
{
m=arr[i];
k=i;
}
}
cout<<"\n\n*********MOST MARKS OBTAINED*********";
cout<<"\nMARKS SCORED BY MOST STUDENTS: "<<k*10<<"-"<<(k*10)+10;
}
};
int main()
{
Student s;
s.get_data();
s.display_data();
s.average();
s.max_min();
s.display_absent();
s.most_marks();
return 0;
}