欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java入门------else...if------成绩查询小程序

程序员文章站 2024-01-05 23:43:34
...
import java.util.Scanner;
public class Demo {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		System.out.println("请输入成绩:");
		double score=scan.nextDouble();
		if(score>=0&&score<60){
			System.out.println("成绩为差");
		}else if(score>=60&&score<80){
			System.out.println("成绩中等");
		}else if(score>=80&&score<90){
			System.out.println("成绩为良");
		}else if(score>=90&&score<=100){
			System.out.println("成绩优秀");
		}else {
			System.out.println("成绩输入错误,请重新运行!");
		}		
	}
}
import java.util.Scanner;
public class Demo1 {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		System.out.println("请输入成绩:");
		int score=scan.nextInt();
		if(score>=90){
			System.out.println("优");
		}else if(score>=80){
			System.out.println("良");
		}else if(score>=60){
			System.out.println("中");
		}else if(score>=0){
			System.out.println("差");
		}
	}
}