我收到错误代码
u180921.java:2:error: ';' expected
在ConText中
import javax.swing.JOptionPane;
import java.util.Scanner
public class u180921 {
public static void main(String args[]) {
String s = JOptionPane.showInputDialog("Bitte Zahl eingeben");
int i = Integer.parseInt( s );
double z, erg;
Scanner sc = new Scanner(System.in);
int arr[] = new int[7];
for (i = 0; i < 7; i++) {
acc(i) = sc.next;
}
for (i = 0; i < 7; i++) {
scc[i] += z;
}
erg = z / 7;
}
}
我做错了什么?
答案 0 :(得分:0)
变量z
,erg
未初始化。 import java.util.Scanner
工作代码为
import javax.swing.JOptionPane;
import java.util.Scanner;
public class u180921{
public static void main(String args[]){
String s = JOptionPane.showInputDialog("Bitte Zahl eingeben");
int i = Integer.parseInt( s );
double z = 0;
double erg = 0;
Scanner sc = new Scanner(System.in);
int arr[] = new int[7];
for(i=0;i<7;i++){
arr[i] = Integer.parseInt(sc.next());
}
for(i=0;i<7;i++) {
arr[i] += z;
}
erg = z / 7;
}
}