Created
August 12, 2016 04:59
-
-
Save portablejim/e3b7a6b18bc9d003d556c7d560702ec8 to your computer and use it in GitHub Desktop.
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
import java.util.Scanner; | |
class Grade { | |
double mark; | |
String grade; | |
/** Construct a Grade with a specified mark*/ | |
public Grade(double m) { | |
mark = m; | |
} | |
/** Return the obtained grade*/ | |
public String getGrade() { | |
if (mark >= 85 && mark <= 100) { | |
grade = "High Distinction"; | |
} else if (mark >= 75 && mark < 84) { | |
grade = "Distinction"; | |
} else if (mark >= 65 && mark < 75) { | |
grade = "Credit"; | |
} else if (mark >= 50 && mark < 65) { | |
grade = "Pass"; | |
} else if (mark >= 0 && mark < 50) { | |
grade = "Fail"; | |
} else { | |
grade = "Mark does not match"; | |
} | |
return grade; | |
} | |
} | |
public class GradeCal { | |
public static void main(String[] args) { | |
//declare scanner object to read the keyboard | |
Scanner input = new Scanner(System.in); | |
//reads mark | |
System.out.print("Enter mark: "); | |
Double examMark = input.nextDouble(); | |
Grade ob = new Grade(examMark); | |
System.out.println("You got " + ob.mark + " mark so your grade is " + | |
ob.getGrade()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment