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

  • Home
  • SEARCH
  • 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 842915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:02:32+00:00 2026-05-15T06:02:32+00:00

userAnswer[] holds the string of the answer the user types in and is comparing

  • 0

userAnswer[] holds the string of the answer the user types in and is comparing it to answers[] to see if they match up and then spits out correct or wrong. j is equal to the question number. So if j was question 6, answers[j] should refer to answers[6] right?
Then userAnswer[6] should compare to answers[6] and match if its correct. But its giving me wrong answers and displaying the answer I typed as correct.

int abc, loopCount = 100;
int j = quesNum, overValue, forLoop = 100;

for (int loop = 1; loop < loopCount; loop++)
{
    aa = r.nextInt(10+1);
    abc = (int) aa;

    String[] userAnswer = new String[x];

    JOptionPane.showMessageDialog(null,abc);

    if(abc < x)
    {
        userAnswer[j] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]);

        if(userAnswer[j].equals(answers[j]))
        {
            JOptionPane.showMessageDialog(null,"Correct. \nThe Correct Answer is "+answers[abc]);
        }
        else
        {
            JOptionPane.showMessageDialog(null,"Wrong. \n The Correct Answer is "+answers[abc]);
        }//else

    }//if

}//for
  • 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-15T06:02:32+00:00Added an answer on May 15, 2026 at 6:02 am

    Your indices are named poorly, and you mix them up yourself. You want to check answers[abc] and not answers[j] against userAnswer[j].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a script to grade a user response by comparing two
I have a question my db model looks like: class UserAnswer (db.Model): user =
I have an option in my form which if the user answer yes would
In a Swing app a method should continue only after user enters a correct
I am using Android to create a app. Where user answer are store on
I have a GridView bound to an ICollection<UserAnswer> that needs to show two columns:
I'm having a problem with my nested form. Models: class UserAnswer < ActiveRecord::Base belongs_to
I am making some view functions to calculate the rank of one user in
I defined these 3 models in Rails3. class User < ActiveRecord::Base has_many :questions has_many
I'm trying to figure out how to do a table join in one of

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.