Answer to Question #14897 in Java | JSP | JSF for Kaze
2012-09-13T09:22:24-04:00
Write a method getGrade:
public static String getGrade(int score){
which gets a student score (as an integer value >= 0) as a parameter. The method returns the student's grade as a String, based on the score:
Score: Grade returned:
0...10 Fail
11...25 D
26...40 C
41...55 B
56... A
1
2012-09-14T10:13:03-0400
public class Main { public static void main(String[] args) { for(int i=0;i<=100;i++){ System.out.println(i+"= "+getGrade(i)); } } public static String getGrade(int score){ String grade=""; if (score >= 0 && score <= 10) { grade = "Fail"; } if (score >= 11 && score <= 25) { grade = "D"; } if (score >= 26 && score <= 40) { grade = "C"; } if (score >= 41 && score <= 55) { grade = "B"; } if (score >= 56 && score <= 100) { grade = "A"; } return grade; } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments
Leave a comment