返回列表 發帖

救命,老師快救我。阿阿阿阿阿阿阿阿阿阿

  1. import java.io.*;
  2. import java.util.*;
  3. public class jva110
  4. {
  5.         public static void main(String arg[])
  6.         {
  7.        
  8.         //取得出題數量
  9.         int userItemCoount = arg.length / 2;
  10.        
  11.         //是否為使用者出題(自由出題)
  12.         Boolean isUserItem = (userItemCoount > 0);
  13.        
  14.         //宣告題目陣列
  15.         String itemQue[];
  16.         String itemAns[];
  17.         //判斷是否是自由出題
  18.                 if(isUserItem)
  19.                 {
  20.                 //是自由出題
  21.                
  22.                 //建立陣列
  23.                 itemQue = new String[userItemCoount];
  24.                 itemAns = new String[userItemCoount];
  25.                 //寫入題目
  26.                         for(int i=0;i<arg.length;i+=2)
  27.                         {
  28.                                 itemQue[i/2] = arg[i];
  29.                                 itemAns[i/2] = arg[i+1];
  30.                         }
  31.                 }else{
  32.                 //是預設題目
  33.                         itemQue = new String[]{"電腦","資料庫","語法","學校","假期"};
  34.                         itemAns = new String[]{"computer","database","syntax","school","Vocation"};
  35.                 }
  36.         //紀錄開始時間
  37.         long startTime = new Date().getTime();
  38.        
  39.         //顯示資訊
  40.         System.out.println("請將題目的中文字彙翻譯成英文單字!");
  41.         System.out.println("輸入英文單字答案後請按Enter鍵:\n");
  42.        
  43.         //輸入擷取物件
  44.         Scanner scanner =new Scanner(System.in);
  45.        
  46.         //宣告答對題目數變數
  47.         int Right=0;
  48.         //開始出題
  49.                         for(int i=0;i<itemQue.length;i++)
  50.                         {
  51.                         System.out.println("第" + (i+1) +"題__ " + itemQue[i]);
  52.                         String useInput = scanner.next();
  53.                
  54.                         String ans = itemAns[i].toLowerCass();
  55.                         useInput = useInput.toLowerCass();
  56.                        
  57.                                 if(useInput.equals(ans))
  58.                                 {
  59.                                 System.out.println("答對了!");
  60.                                 Right++;
  61.                                 }else{
  62.                                 System.out.println("答錯了!");
  63.                                 System.out.println("正確答案是" + itemAns[i]+"\n");
  64.                                 }
  65.                        
  66.                         }
  67.         //結算時間
  68.         long endTime = new Date().getTime();
  69.         long useTime = (endTime-startTime)/1000;
  70.        
  71.         System.out.println("你使用了" + useTime + "秒,在" + itemQue.length + "題中答對了" + Right + "題");
  72.         }
  73. }
複製代碼
老師,為甚麼一直有兩個錯誤訊息 ( ?. h: w2 U- _# }9 C, R
錯誤訊息如下% Z% ~  M0 t  s2 Z, L
jva110.java:54: error: cannot find symbol* k: ]7 F0 p9 e7 E$ K
                        String ans = itemAns.toLowerCass();
* O' L0 {+ n' V, \                                               ^
' d& O8 A2 |8 M  symbol:   method toLowerCass()
! A' ?+ s* V0 h* B" S  location: class String" A9 w1 v8 Z1 W4 |' e( S& K9 ~
jva110.java:55: error: cannot find symbol
! d# S: G( A! H  q3 w# I                        useInput = useInput.toLowerCass();" ?9 `& W- J4 b4 z2 r. M" ^$ v0 z/ a
                                           ^
2 L! w, w- Y: ~( Q( A* ?5 F* _  symbol:   method toLowerCass()
& J+ l% K( p; _: r9 F  location: variable useInput of type String
' j& G! Z, d1 \' E2 ]/ I2 errors
水桶小鄭,鯰魚

小雲雀

TOP

回復 1# TOM
, J+ ?- Z( [7 T( L
, x, L5 ~. ?* r& x8 V5 B, @# Q. I7 |不知!~©©©©©©©©

TOP

是toLowerCase();不是toLowerCass();2 ^0 a) _7 V1 u
7 b: ?  D" K' U4 p

  f. Y* E' v& t; \: c. H String ans = itemAns[i].toLowerCase();
1 F% h* L# M: Y4 _7 w useInput = useInput.toLowerCase();
★ 嘉凱~~☆

TOP

返回列表