-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent1.java
More file actions
33 lines (32 loc) · 1.03 KB
/
Student1.java
File metadata and controls
33 lines (32 loc) · 1.03 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
//Question 4: Design an application in java that contains a class Student having properties.......
public class Student1 {
String name;
double percentage;
Student1(String n, double p) {
name = n;
percentage = p;
}
}
class Test{
public static void print() {
Student1 obj = new Student1("Siya", 67.90);
Student1 obj1 = new Student1("Riya", 89.40);
Student1 obj2 = new Student1("Diya", 96.67);
double top = Math.max(Math.max(obj.percentage,obj1.percentage),obj2.percentage);
if (top == obj.percentage){
System.out.println(obj.name);
System.out.println(obj.percentage);
}
else if (top == obj1.percentage){
System.out.println(obj1.name);
System.out.println(obj1.percentage);
}
else {
System.out.println(obj2.name);
System.out.println(obj2.percentage);
}
}
public static void main(String[] args) {
Test.print();
}
}