Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
package csdncom.tt;
import java.util.Scanner;
/** * Created by Administrator on 2021/10/30. */
public class LeapYear {
public static void main(String[] args){
System.out.println("Please enter a score");
// Define the input fraction as "mark", and the fraction will have decimals
double mark;
Scanner scanner = new Scanner(System.in);
mark = scanner.nextDouble();
// Determine if there are any input errors.
if(mark<0||mark>100){
System.out.println("Wrong input! "); System.exit(0);
}
/* The grade of judging scores is A with 90 points above, B with 80 to 89 points, C with 70 to 79 points, D with 60 to 69 points, and E with 60 points below */
if (mark>=90) {
System.out.println("this mark is grade \'A\' ");
}else if (mark>=80) {
System.out.println("this mark is grade \'B\' ");
}else if (mark>=70) {
System.out.println("this mark is grade \'C\' ");
}else if (mark>=60) {
System.out.println("this mark is grade \'D\' ");
}else System.out.println("this mark is grade \'E\' "); }}Copy the code