- import java.util.Scanner;
- public class sdf {
- public static void main(String[] args) {
- while (true)
- {
- Scanner s=new Scanner(System.in);
- float str;
- System.out.println("請輸入你的成績:");
- str=s.nextFloat();
- if(str>=90&&str<=100)
- System.out.print("優");
- else if(str>=80&&str<=89)
- System.out.print("甲");
- else if(str>=70&&str<79)
- System.out.print("乙");
- else if(str>=60&&str<=69)
- System.out.print("丙");
- else if(str>=0&&str<=60)
- System.out.print("丁");
- else
- System.out.print("輸入錯誤!");
- System.out.println(str+"\n");
- }
- }
- }
複製代碼 |