0

我的目标是编写一个名为 Sleep 的实用程序类,其中包含一个名为 iqLoss 的静态方法。iqLoss 方法应该采用一个参数:一个整数,表示在给定的夜晚错过的睡眠小时数。然后返回一个整数,表示由于睡眠剥夺而导致的智商下降。我不知道问题是什么,因为我只是 Java 的初学者。我正在为我的班级使用一个名为“Codio”的 IDE,所以有些东西我无法使用它,我不知道 IDE 的局限性。我已经在下面发布了主要和类,任何提示将不胜感激。

public class Sleep{
  public static int iqLoss(){
    int iq;
    int totaliqloss;
    if(iq >= 2){
      totaliqloss = totaliqloss + 2;
    }else if(iq<=2){
      totaliqloss = totaliqloss + 1;
    }
    return totaliqloss;
  }
}
public class SleepCalc {
    public static void main(String[] args) {
    int iq;
    int normalsleep;
    
    System.out.println("What is your IQ (when fully rested)");
    iq = ConsoleIO.readInt();
    
    System.out.println("How many hours do you noramlly get");
    normalsleep = ConsoleIO.readInt();
    
    
    System.out.println("How many hours did you get last night?");
    int sleep;
    sleep = ConsoleIO.readInt;
    sleep = normalsleep - sleep;
    sleep = Sleep.iqLoss();

    System.out.println("How many hours did you get the night before last?");
    int sleep2;
    sleep2 = ConsoleIO.readInt;
    sleep2 = normalsleep - sleep2;
    sleep2 = Sleep.iqLoss();
    
    System.out.println("How many hours did you get the night before the night before last?");
    int sleep3;
    sleep3 = ConsoleIO.readInt;
    sleep3 = normalsleep - sleep3;
    sleep3 = Sleep.iqLoss();
    
    iq = iq - sleep - sleep2 - sleep3;
  }
}
SleepCalc.java:21: error: cannot find symbol
    sleep = ConsoleIO.readInt;
                     ^
  symbol:   variable readInt
  location: class ConsoleIO
SleepCalc.java:27: error: cannot find symbol
    sleep2 = ConsoleIO.readInt;
                      ^
  symbol:   variable readInt
  location: class ConsoleIO
SleepCalc.java:33: error: cannot find symbol
    sleep3 = ConsoleIO.readInt;
                      ^
4

0 回答 0