我遇到了问题。我写了一个程序,它允许我计算一个特定的数字,并能够使用前缀和后缀。我需要这个来构建另一个程序。
这是我的代码(// offen是德语for open,// zu for closed)
public class zael{ //offen1
public static void main(String[] args){//offen2
int z = 0;
System.out.println("Bis welche Zahl willst du zaelen?");
String keins = System.console().readLine();
int k = Integer.parseInt(keins);
System.out.println("Willst du einen prefix? (Y/N)");
String p = System.console().readLine();
if (p.equals ("Y")){//offen3
System.out.println("Gib deinen Prefix an!");
String pref = System.console().readLine();
}//zu3
System.out.println("Willst du einen Suffix? (Y/N)");
String s = System.console().readLine();
if (s.equals ("Y")) {//offen4
System.out.println("Gib deinen Suffix an!");
String suff = System.console().readLine();
}//zu4
if (p.equals ("Y")){//offen5
while(z < k) {//offen6
if (s.equals ("Y")) {//offen7
System.out.println(pref);
System.out.print(z+1);
System.out.print(suff);
z = z + 1;
}//zu7
else {//offen8
System.out.println(pref);
System.out.print(z+1);
z = z + 1;
}//zu8
}//zu6
}//zu5
else {//offen9
while (z < k){//offen10
if (s.equals ("Y")) {//offen11
System.out.println("Gib deinen Suffix an!");
String suff = System.console().readLine();
System.out.println(z+1 + suff);
z = z + 1;
}//zu11
else{//offen12
System.out.println(z+1);
z = z + 1;
}//zu12
}//zu10
}//zu9
}//zu2
}//zu1
我得到的错误是:
zael.java:22: error: cannot find symbol
System.out.println(pref);
^
symbol: variable pref
location: class zael
zael.java:24: error: cannot find symbol
System.out.print(suff);
^
symbol: variable suff
location: class zael
zael.java:28: error: cannot find symbol
System.out.println(pref);
^
symbol: variable pref
location: class zael
3 errors