Created
September 25, 2015 08:25
-
-
Save mhaidarhanif/665807229a58ea95f69d to your computer and use it in GitHub Desktop.
Student Grading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Grade { | |
public String gradeScore(int score) { | |
String result = ""; | |
if (score >= 60) { | |
result = "lulus"; | |
} else if (score >= 40) { | |
result = "nyaris lulus"; | |
} else if (score >= 0) { | |
result = "tidak lulus"; | |
} else if (score < 0) { | |
result = "tidak jelas"; | |
} | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RunGrading { | |
public static void main(String[] args) { | |
Student adi = new Student("Adi", 90); | |
Student budi = new Student("Budi", 20); | |
Student ceri = new Student("Ceri", 0); | |
Student debi = new Student("Debi", 60); | |
Student endi = new Student("Endi", -10); | |
Student[] students = new Student[5]; | |
students[0] = adi; | |
students[1] = budi; | |
students[2] = ceri; | |
students[3] = debi; | |
students[4] = endi; | |
Grade grader = new Grade(); | |
for (int x = 0; x < students.length; x++) { | |
System.out.print( students[x].getName() + " nilainya " + students[x].getScore() ); | |
System.out.println( " dinyatakan " + grader.gradeScore(students[x].getScore()) ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
public String name; | |
public int score; | |
public Student(String name, int score) { | |
this.name = name; | |
this.score = score; | |
} | |
public String getName() { | |
return this.name; | |
} | |
public int getScore() { | |
return this.score; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment