Java入門クラスの宿題に取り組んでいます。コードをコンパイルしようとすると、コンパイル エラーが発生します。単純なことだと思いますが、エラーの原因がわかりません。
私が受け取っているエラーはソースコードの下にあることに注意してください。
/* Logical Design
start
// Declarations
final String QUESTIONS[] = new String{"Please input your answer using A, B, or C.\nWho is the coolest guy ever? \n\nA. Max\nB. James Bond\nC. Burt Reynolds", "Please input your answer using A, B, or C.\nWho do coolguys' drive?\n\nA. Datuns\nB. Panters\nC. Porsches", "Please input your answer using A, B, or C.\nWhat is the coolest city?\n\nA. Los Angles\nB. Denver\nC.Boulder"};
final String CONGRATS = "You got it right!"
final string FAIL = "Horribly. Horribly wrong. =["
final String ANSWERS[] = new String{"A","A","A"};
final String QUIT = "QUIT";
String tempanswer[] = new String[3]
int index;
int index2;
String keeplaying;
Output "Would you like to play?"
input keeplaying
if(keepplaying == QUIT) {
return;
} else {
for(index = 0; index<QUESTIONS.length; index++) {
Output QUESTIONS[index]
input tempanswer[index];
for(index2 = 0; index2<ANSWERS.length; index2++) {
if tempanswer == ANSWERS[index2] {
output CONGRATS } else { output FAIL }
}
}
}
stop
*/
import javax.swing.*;
import java.awt.event.*;
public class FunQuiz
{
public static void main(String args[])
{
final String QUESTIONS[] = {"Please input your answer using A, B, or C.\nWho is the coolest guy ever? \n\nA. Max\nB. James Bond\nC. Burt Reynolds", "Please input your answer using A, B, or C.\nWhat do coolguys' drive?\n\nA. Datuns\nB. Panters\nC. Porsches", "Please input your answer using A, B, or C.\nWhat is the coolest city?\n\nA. Los Angles\nB. Denver\nC.Boulder"};
final String ANSWERS[] = {"A","A","A"};
final String QUIT = "QUIT";
String tempanswer[] = new String[3];
int index;
int index2;
String keeplaying;
keepplaying = JOptionPane.showInputDialog("Would you like to play?");
if(keepplaying == QUIT) {
return;
} else {
for(index = 0; index<QUESTIONS.length; index++) {
System.out.println(QUESTIONS[index]);
JOptionPane.showInputDialog(tempanswer[index]);
for(index2 = 0; index2<ANSWERS.length; index2++) {
if(tempanswer == ANSWERS[index2]) {
System.out.println("You got question " . index2 . " correct!");} else { System.out.println("You got question " . index2 . " incorrect.");}
}
}
}
System.exit(0);
}
}
これらはコンパイル時に発生するエラーです
FunQuiz.java:57: <identifier> expected
System.out.println("You got question " . index2 . " correct!");} else { System.out.println("You got question " . index2 . " incorrect.");}
^
FunQuiz.java:57: ';' expected
System.out.println("You got question " . index2 . " correct!");} else { System.out.println("You got question " . index2 . " incorrect.");}