Created
November 4, 2013 18:18
-
-
Save henvic/7306930 to your computer and use it in GitHub Desktop.
Score
This file contains hidden or 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
package example; | |
import java.util.Scanner; | |
public class HelloWorld { | |
public static char getScoreLabel(float score) { | |
if (score < 0 || score > 10) { | |
return '-'; | |
} | |
if (score >= 8.5) { | |
return 'A'; | |
} | |
if (score >= 7.0) { | |
return 'B'; | |
} | |
if (score >= 5.0) { | |
return 'C'; | |
} | |
if (score >= 3.0) { | |
return 'D'; | |
} | |
return 'E'; | |
} | |
public static void main(String[] args) { | |
float score; | |
Scanner input = new Scanner(System.in); | |
System.out.print("Score: "); | |
score = input.nextFloat(); | |
System.out.println("Result: " + getScoreLabel(score)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment