-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGradeTracker_BB.java
More file actions
169 lines (158 loc) · 4.9 KB
/
GradeTracker_BB.java
File metadata and controls
169 lines (158 loc) · 4.9 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import java.util.*;
class Student
{
int size;
int class_size;
int snum;
String ID;
String name;
String sub1;
String sub2;
String sub3;
int marks1;
int marks2;
int marks3;
Student[] arr = new Student[50];
Scanner input=new Scanner(System.in);
void getDetails()
{
if(size>100)
{
System.out.print("can't add more than 50 students");
return;
}
else
{
arr[size]=new Student();
System.out.print("Enter Student ID: ");
arr[size].ID=input.next();
System.out.print("Enter Student Name: ");
arr[size].name=input.next();
System.out.print("Enter Subject1: ");
arr[size].sub1=input.next();
System.out.print("Enter marks: ");
arr[size].marks1=input.nextInt();
System.out.println();
System.out.print("Enter Subject2: ");
arr[size].sub2=input.next();
System.out.print("Enter marks: ");
arr[size].marks2=input.nextInt();
System.out.println();
System.out.print("Enter Subject3: ");
arr[size].sub3=input.next();
System.out.print("Enter marks: ");
arr[size].marks3=input.nextInt();
System.out.println();
size++;
}
}
void displayStudent(String id)
{
int count=0;
for(int i=0;i<size;i++)
{
if(arr[i].ID.equals(id))
{
count++;
System.out.println("Student found!!");
System.out.println("");
System.out.println("Name: "+arr[i].name);
System.out.println(arr[i].sub1+": "+arr[i].marks1);
System.out.println(arr[i].sub2+": "+arr[i].marks2);
System.out.println(arr[i].sub3+": "+arr[i].marks3);
System.out.println("");
}
}
if(count==0)
{
System.out.println("Student id not found.");
}
}
void average(String id)
{
int count=0;
for(int i=0;i<size;i++)
{
if(arr[i].ID.equals(id))
{
count++;
System.out.println("Student found!!");
System.out.print("Average marks for "+arr[i].name+": "+(double)(arr[i].marks1+arr[i].marks2+arr[i].marks3)/3);
}
}
if(count==0)
{
System.out.println("Student id not found.");
}
}
void highestAverage(int ave)
{
int count=0;
for(int i=0;i<size;i++)
{
int Average=(arr[i].marks1+arr[i].marks2+arr[i].marks3)/3;
if(Average>ave)
{
count++;
System.out.print("ID: "+arr[i].ID);
System.out.print("Name: "+arr[i].name);
System.out.print("Average: "+(arr[i].marks1+arr[i].marks2+arr[i].marks3)/3);
System.err.println();
}
}
if(count==0)
{
System.out.print("No student average is grater than "+ave);
}
}
}
class grade_Tracker
/*----------------------------------Coded by Binary Brains----------------------------------*/
{
public static void main(String s[])
{
Student obj=new Student();
Scanner input = new Scanner(System.in);
while (true)
{
System.out.print("\nEnter choice:\n1. ENTER STUDENT DETAILS\n2. VIEW STUDENT GRADES\n3. CALCULATE AVERAGE\n4. DISPLAY STUDENTS WITH HIGH AVERAGE\n5. EXIT\n-->");
int choice = input.nextInt();
switch(choice)
{
case 1:
{
obj.getDetails();
break;
}
case 2:
{
System.out.print("Enter Student ID: ");
String id=input.next();
obj.displayStudent(id);
break;
}
case 3:
{
System.out.print("Enter Student ID: ");
String id=input.next();
obj.average(id);
break;
}
case 4:
{
System.out.print("Enter threshold average: ");
int ave=input.nextInt();
obj.highestAverage(ave);
break;
}
case 5:
{
System.out.println("Exits...");
return;
}
default :
System.out.println("pls.. enter valid choice.");
}
}
}
}