Skip to content

Instantly share code, notes, and snippets.

@henvic
Created November 4, 2013 18:18
Show Gist options
  • Save henvic/7306930 to your computer and use it in GitHub Desktop.
Save henvic/7306930 to your computer and use it in GitHub Desktop.
Score
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