Dunno why it is...heres the coding for it.
/**********************************\
* *
* Multiplication Quiz *
* Developed and Written by: *
* Nick Gibson *
* CIT *
* ***Finished Code*** *
* *
\**********************************/
import javax.swing.JOptionPane;
import java.awt.*;
import java.lang.Math.*;
import java.util.*;
import javax.swing.*;
import java.text.*;
import java.text.DecimalFormat.*;
import java.io.*;
import java.lang.Integer.*;
public class TestMaker
{
public static void main(String[] args)
{
int y = 1, x, quesNum = 1, z, zz, qq, g, u = 1;
while (y == 1)
{
String xx = JOptionPane.showInputDialog(null,"How many questions is this test? \n(May be 1 - 99 questions)");
x = Integer.parseInt(xx);
if(x > 99 || x < 1)
{
JOptionPane.showMessageDialog(null,"Invalid number. Please try again.", "Invalid Number", JOptionPane.ERROR_MESSAGE);
}
else
{
String[] questions = new String[25];
String[] answers = new String[25];
String[] a = new String[25];
String[] b = new String[25];
String[] c = new String[25];
String[] d = new String[25];
while(u == 1)
{
questions[1] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[1] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[1] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[1] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[1] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[1] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[2] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[2] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[2] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[2] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[2] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[2] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[3] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[3] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[3] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[3] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[3] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[3] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[4] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[4] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[4] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[4] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[4] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[4] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[5] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[5] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[5] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[5] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[5] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[5] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[6] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[6] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[6] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[6] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[6] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[6] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[7] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[7] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[7] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[7] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[7] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[7] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[8] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[8] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[8] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[8] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[8] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[8] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[9] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[9] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[9] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[9] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[9] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[9] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
questions[10] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+quesNum);
a[10] = JOptionPane.showInputDialog(null,"What is the answer for a?");
b[10] = JOptionPane.showInputDialog(null,"What is the answer for b?");
c[10] = JOptionPane.showInputDialog(null,"What is the answer for c?");
d[10] = JOptionPane.showInputDialog(null,"What is the answer for d?");
answers[10] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
quesNum++;
if(quesNum > x)
{
break;
}
}//while
zz = JOptionPane.showConfirmDialog(null,"All questions are completed. \nWould you like to review any questions?", "Question Review", JOptionPane.YES_NO_OPTION);
if(zz == JOptionPane.YES_OPTION)
{
while(u == 1)
{
String q = JOptionPane.showInputDialog(null,"Which question would you like to review? \n\nCurrently on Question "+quesNum+"\n\nPress 0 to exit.");
qq = Integer.parseInt(q);
if(qq == 0)
{
break;
}
JOptionPane.showMessageDialog(null,"You are now going to edit question "+qq);
questions[qq] = JOptionPane.showInputDialog(null,"Question: "+questions[qq]+"\nType in the correct question.");
a[qq] = JOptionPane.showInputDialog(null,"A: "+a[qq]+"\nType in answer A");
b[qq] = JOptionPane.showInputDialog(null,"B: "+b[qq]+"\nType in answer B");
c[qq] = JOptionPane.showInputDialog(null,"C: "+c[qq]+"\nType in answer C");
d[qq] = JOptionPane.showInputDialog(null,"D: "+d[qq]+"\nType in answer D");
answers[qq] = JOptionPane.showInputDialog(null,"Answer: "+answers[qq]+"\nPlease type the correct answer. \nType in lowercase a - d");
JOptionPane.showMessageDialog(null,questions[qq]+"\n\nA: "+a[qq]+"\nB: "+b[qq]+"\nC: "+c[qq]+"\nD: "+d[qq]+"\n\nCorrect Answer: "+answers[qq]);
}//while
}//if
if(quesNum > x)
{
JOptionPane.showMessageDialog(null,"That concludes the creation portion of the test. \nIt is now time to take the test.");
}
JOptionPane.showMessageDialog(null,"When you ready for the test, press OK.");
double number1 = (Math.random() * 10);
double number2 = (Math.random() * 10);
double number3 = (Math.random() * 10);
long aa, bb, cc, ss;
int abc;
aa = Math.round(number1);
bb = Math.round(number2);
cc = Math.round(number3);
ss = aa;
String str = Long.toString(ss);
abc = Integer.parseInt(str);
JOptionPane.showMessageDialog(null,questions[abc]+"\n\n"+a[abc]+"\n"+b[abc]+"\n"+c[abc]+"\n"+d[abc]);
}//else
}//while y = 1
}//public main
}//public class
I know theres a lot of repetitiveness in the coding...but its because the arrays were retuning null so I got tired of messing with them.
Everything works until it reaches line 224, which returns null values.