Answer to Question #14897 in Java | JSP | JSF for Kaze

Question #14897
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
Expert's answer
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal