Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 819715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:21:25+00:00 2026-05-15T02:21:25+00:00

Dunno why it is…heres the coding for it. http://pastebin.org/301343 /**********************************\ * * * Multiplication

  • 0

Dunno why it is…heres the coding for it.

http://pastebin.org/301343

/**********************************\
*                                  *
*       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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:21:26+00:00Added an answer on May 15, 2026 at 2:21 am

    null is a valid value for an array. Both the pointer to the array and the contents in the array may be null. I took the time to read your too-long code. It looks like your code is not filling the arrays completely. For one thing, you do not put anything in slot 0 (questions[0] is always null).

    Also, your code should be a for loop. And you should allocate the arrays to the number of questions allowed, not a fixed number. This way you will be certain that your arrays have no null elements (assuming JOptionPane doesn’t return null if the user doesn’t enter any value).

    String[] questions = new String[x];
    String[] answers = new String[x];
    String[] a = new String[x];
    String[] b = new String[x];
    String[] c = new String[x];
    String[] d = new String[x];
    
    for (int i = 0; i < x; i++)
    {
    
      questions[i] = JOptionPane.showInputDialog(null,"Please Enter Question Number "+i);
      a[i] = JOptionPane.showInputDialog(null,"What is the answer for a?");
      b[i] = JOptionPane.showInputDialog(null,"What is the answer for b?");
      c[i] = JOptionPane.showInputDialog(null,"What is the answer for c?");
      d[i] = JOptionPane.showInputDialog(null,"What is the answer for d?");
      answers[i] = JOptionPane.showInputDialog(null,"What is the correct answer to the question. \nType in lowercase a - d.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First of all, it's a really bad idea to use… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer If you are not dead set on using a listbox,… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer killproc will terminate programs in the process list which match… May 16, 2026 at 9:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

i dunno, but will your machine suffer great slowdown if you use a very
I dunno about USA and the UK, but in India, schools still teach GW-BASIC.
I dunno why, but first pixel (left bottom) is loaded correctly, but the others
I dunno if this should go in a Math forum or a Programming forums,
i dunno if the question is already ask, but i couldn't find it... i'm
I'm toying around with GWT (dunno if this matters) and Hibernate. I've created a
Alright, this might be simple but I dunno how to do it! I have
SOLVED in the last answer im getting following error, dunno where and why? cause
I want to display 2 columns of images using float:left, and I dunno why

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.