package javaapplication1;
class Student
{
private int rollNo;
private String name;
private double marks;
public Student(int rollNo, String name, double marks) {
this.rollNo = rollNo;
this.name = name;
this.marks = marks;
}
public double getMarks() {
return marks;
}
public void setMarks(double marks) {
this.marks = marks;
}
public int getRollNo() {
return rollNo;
}
public String getName() {
return name;
}
}
package javaapplication1;
class StudentDemo
{
public static void main(String args[])
{
Student one =new Student(1,"Ravi",45);
Student two =new Student(2,"Ravish",95);
Student three =new Student(3,"Ravindra",75);
System.out.println("Highest is "+compareHighest(one,two,three));
}
public static String compareHighest(Student one,Student two,Student three)
{
Student st=one;
if(st.getMarks()<two.getMarks())
{
st=two;
}
if(st.getMarks()<three.getMarks())
{
st=three;
}
return st.getName();
}
}
0 comments:
Post a Comment