返回列表 發帖
  1. package text369;
  2. import java.lang.System;
  3. import java.util.Scanner;
  4. public class text123 {
  5. public static void main(String[] args) {
  6. float x;
  7. Scanner s=new Scanner(System.in);
  8. System.out.println("請輸入你的成績:");
  9. x=s.nextFloat();
  10. if(x>=90 && x<=100)
  11. {
  12.     System.out.print("優");   
  13. }
  14. else if(x>=80 && x<90)
  15. {
  16.     System.out.print("甲");   
  17. }
  18. else if(x>=70 && x<80)
  19. {
  20.     System.out.print("乙");   
  21. }
  22. else if(x>=60 && x<70)
  23. {
  24.     System.out.print("丙");   
  25. }
  26. else if(x>=0 && x<60)
  27. {
  28.     System.out.print("丁");   
  29. }
  30. else
  31. {
  32. System.out.print("輸入錯誤");   
  33. }

  34.         }

  35. }
複製代碼
張閎鈞OuO

TOP

  1. package text369;
  2. import java.lang.System;
  3. import java.util.Scanner;
  4. public class text123 {
  5. public static void main(String[] args) {
  6. while(true)
  7.     {float x;
  8. Scanner s=new Scanner(System.in);
  9. System.out.println("請輸入你的成績:");
  10. x=s.nextFloat();
  11. if(x>=90 && x<=100)
  12. {
  13.     System.out.println("優");   
  14. }
  15. else if(x>=80 && x<90)
  16. {
  17.     System.out.println("甲");   
  18. }
  19. else if(x>=70 && x<80)
  20. {
  21.     System.out.println("乙");   
  22. }
  23. else if(x>=60 && x<70)
  24. {
  25.     System.out.println("丙");   
  26. }
  27. else if(x>=0 && x<60)
  28. {
  29.     System.out.println("丁");   
  30. }
  31. else
  32. {
  33. System.out.println("輸入錯誤");   
  34. }

  35.         }

  36. }
  37. }
複製代碼
張閎鈞OuO

TOP

返回列表