**I am doing a mini project, I need help with how I can store the scores in an array. **
import javax.swing.*; // import the swing library for I/O
class fi_project
{
public static void main (String[] param)
{
questionfilm();
System.exit(0);
} // END main
//************************************************************
public static void questionfilm()
{
//* I am declaring my variables
String user1 = "";
String user2 = "";
String user3 = "";
String user4 = "Alohomora";
String user5 = "";
String user6 = "";
String user7 = "";
String user8 = "Potter";
String user9 = "";
String user10 = "";
String user11 = "";
String user12 = "Revealer";
JOptionPane.showMessageDialog(null, "<html>Welcome to the Harry Potter mini quiz!" + "<br>Players needed: 3</html>");
JOptionPane.showInputDialog("Enter your name: ");
String name = "";
for (int i=1; i<=3; i++) //* The loop will stop until the condition is met
{
user1 = JOptionPane.showInputDialog("Player " +i+ ": What spell opens a locked door?"); //variable 'user1' gets value of user input
user2 = JOptionPane.showInputDialog("Is " +user1+ " your final answer? " + "Y/N"); //variable 'user2' gets value of user's second input
if (user2.equals("Y") || user2.equals("y"))
{
if (user1.equals("Alohomora") || user1.equals("alohomora") || user1.equals("ALOHOMORA")) //checks if user's answer is correct (if is the same as value of user4)
{
JOptionPane.showMessageDialog(null, "Your final answer is: " +user1);
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue</html>");
}
else //if the answer was wrong program does what in lines 46-48
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: Alohomora</html>");
}
}
else if(user2.equals("N")) //This is in case that user inserted N (If he/she changed the mind.)
{
user3 = JOptionPane.showInputDialog("What is your answer if it was not " +user1 + "?");
if(user3.equals("alohomora") || user3.equals("Alohomora") || user3.equals("ALOHOMORA")) //checks if answer is correct. If not go to line 57
{
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue</html>");
}
else //if answer is wrong
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: </html>" +user4);
}
}
else //if user inserts something different than Y or N
{
JOptionPane.showMessageDialog(null, "Please enter Y/N");
System.exit(0);
}
}
//************************************************************
{
user5 = JOptionPane.showInputDialog("What is Harry's second name?"); //variable 'user1' gets value of user input
user6 = JOptionPane.showInputDialog("Is " +user5+ " your final answer? " + "Y/N"); //variable 'user2' gets value of user's second input
if (user6.equals("Y") || user6.equals("y"))
{
if (user5.equals("Potter") || user5.equals("potter") || user5.equals("POTTER")) //checks if user's answer is correct (if is the same as value of user4)
{
JOptionPane.showMessageDialog(null, "Your final answer is: " +user5);
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue</html>");
}
else //if the answer was wrong program does what in lines 46-48
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: Potter</html>");
}
}
}
if(user6.equals("N")) //This is in case that user inserted N (If the user changed their mind
{
user7 = JOptionPane.showInputDialog("What is your answer if it was not " +user5 + "?");
if(user7.equals("potter") || user7.equals("Potter") || user7.equals("POTTER")) //checks if answer is correct. If not go to line 57
{
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue/html>");
}
else //if answer is wrong
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: Alohomora</html>");
}
}
else //if user inserts something different than Y or N
{
JOptionPane.showMessageDialog(null, "Please enter Y/N");
return;
}
//************************************************************
{
user9 = JOptionPane.showInputDialog("What can be used to make invisible ink appear?"); //variable 'user1' gets value of user input
user10 = JOptionPane.showInputDialog("Is " +user5+ " your final answer? " + "Y/N"); //variable 'user2' gets value of user's second input
if (user10.equals("Y") || user10.equals("y"))
{
if (user9.equals("Revealer") || user9.equals("revealer") || user9.equals("REVEALER")) //checks if user's answer is correct (if is the same as value of user4)
{
JOptionPane.showMessageDialog(null, "Your final answer is: " +user9);
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue</html>");
}
else //if the answer was wrong program does what in lines 46-48
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: Revealer</html>");
}
}
}
if(user10.equals("N")) //This is in case that user inserted N (If the user changed their mind
{
user11 = JOptionPane.showInputDialog("What is your answer if it was not " +user9 + "?");
if(user11.equals("reaveler") || user11.equals("Revealer") || user11.equals("REVEALER")) //checks if answer is correct. If not go to line 57
{
JOptionPane.showMessageDialog(null, "<html>This is the correct answer!" + "<br>Click OK to continue</html>");
}
else //if answer is wrong
{
JOptionPane.showMessageDialog(null, "<html>Wrong answer!" + "<br>The correct answer is: Revealer</html>");
}
}
else //if user inserts something different than Y or N
{
JOptionPane.showMessageDialog(null, "Please enter Y/N");
return;
}
//************************************************************