我正在用 Java 做一个简单的测验,但是我遇到了一些麻烦。
import java.util.Scanner;
public class quiz {
public static void main( String[] args ) {
Scanner keyboard = new Scanner( System.in );
String q1 = "London";
String a1;
int q2 = 20;
int a2;
String q3 = "Java";
String a3;
int score = 0;
System.out.println( "What is the capital of England? ");
a1 = keyboard.next();
if(a1 == q1) {
score + 1;
System.out.println( "Correct!");
}
else if {
System.out.println( "WRONG!" );
}
System.out.println( "What is 10 + 10?" );
a2 = keyboard.nextInt();
if(a2 == q2) {
score + 1;
System.out.println( "Correct!" );
}
else if {
System.out.println( "WRONG" );
}
System.out.println( "What langauge is kevin learning?" );
a3 = keyboard.next();
if(a3 == q3) {
score + 1;
System.out.println( "Correct!" );
}
else if {
System.out.println( "WRONG" );
}
System.out.println( "Your total marks were" score );
}
}