I'm trying to implement a method printDegreeClassification that prints out the degree classification given the average mark of a student. The method should take one argument ob object type Student and return no value. Class student has the following method: public int getAverage(); And classification as following: First 70+, Upper Second 60-67, Lower Second 50-59, Third 40-49 ,Pass 30-39, Fail 0-29
My code is:
public void printDegreeClassification(Student a){
int b = a.getAverage();
if (b>=70){
System.out.println("First");
}else if(b>=60){
System.out.println("Upper Second");
}else if(b>=50){
System.out.println("Lower Second");
}else if(b>=40){
System.out.println("Third");
}else if(b>=30){
System.out.println("Pass");
}else{
System.out.println("Fail");
}
public class Student {
public int getAverage();
}
public static void main(String[] args) {
Student result = new Student();
result.printDegreeClassification(result);
}
}
Am I right? This is my first ever Java program.
getAverage(notavarage) and fix the typos, this would be correct. Note that this is not a code review, there is Code Review for that. But for that this would need to run, what you don't even tried, why ?getAvarageandgetAvartageshould begetAverage.