1. 程式人生 > >作業:用switch語句來分考試成績的等級

作業:用switch語句來分考試成績的等級

import java.util.Scanner;

class DengJi
{
	public static void main(String[] args) 
{
	Scanner scanner = new Scanner(System.in);
	System.out.println("請輸入分數");
	int score=scanner.nextInt();
	switch (score/10) 
{
	case 10:
		System.out.println("優");break;
	case 9:
		System.out.println("優");break;
	case 8:
	System.out.println("良");break;
	case 7:
	System.out.println("中");break;
	default:
System.out.println("差");break;
	}
	}
}