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 6888617
In Process

The Archive Base Latest Questions

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

I am currently trying to write a program which asks the user for a

  • 0

I am currently trying to write a program which asks the user for a three digit number and checks it against a random 3 digit number generate by the computer. The number the user enters must have three unique digits, as the computer number also has three unique digits.
So far I have managed to get the user’s three digit number into an array with one digit in each array position, but I can’t get it to validate properly. It is able to identify two digits being the same, so it would then need to ask the user for a new number that has 3 different digits (i.e. loop back to beginning) until such time as user complies. The System.out.println is just for me to check that it is picking out the double digits. Here is my code so far. This is a method, not the whole program.

public static int[] getUserNumberDebugMode(String compNum){
    final int RANDOM_NUMBER_SIZE = 3;
    int[]userNumber = new int [RANDOM_NUMBER_SIZE];

    String userGuessAsString;

    userGuessAsString = JOptionPane.showInputDialog(compNum + "\n Please enter a number.");
    int number = Integer.parseInt(userGuessAsString);

    // put three digit number individually into array
    for(int loop = (userNumber.length - 1); loop>=0; loop--){
        userNumber[loop]= number%10;
        number = number/10;
    } // end userNumber array populating

    for (int outerloop = 0; outerloop < userNumber.length; outerloop++){
        for (int innerloop = outerloop - 1; innerloop > -1; innerloop --){
            while (userNumber[outerloop] == userNumber [innerloop]){
            System.out.println("user compare: " + outerloop + " with: " + innerloop);
            } // end while loop
        }// end inner loop
    } // end outer loop

    return userNumber;
} // end getUserNumberDebugMode
  • 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-27T06:02:52+00:00Added an answer on May 27, 2026 at 6:02 am

    Have solved the problem by clocking up a unique number check if any of the numbers match, and then putting the whole thing in a do/while loop while the unique number check > 0. Not the most elegant fix I’m sure, but it works and it’ll do.

    do{
            uniqueCheck = 0;
            userGuessAsString = JOptionPane.showInputDialog(compNum + "\n Please enter a number.");
        int number = Integer.parseInt(userGuessAsString);
    
        // put three digit number individually into array
        for(int loop = (userNumber.length - 1); loop>=0; loop--){
            userNumber[loop]= number%10;
            number = number/10;
        } // end userNumber array populating
    
        for (int loop = 0; loop < userNumber.length; loop++){
            for(int innerLoop  = 0; innerLoop < userNumber.length; innerLoop++) {
                if(loop != innerLoop) {
                    if (userNumber[loop] == userNumber[innerLoop] ){
                        JOptionPane.showMessageDialog(null, "Please enter three unique digits!", "ERROR", JOptionPane.ERROR_MESSAGE);
                        uniqueCheck ++;
                    } //  end inner IF loop
                } // end outer IF loop
            } // end inner for loop
        } // end outer for loop
    
        } while (uniqueCheck > 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to write a program in VB.NET which fluidly changes the DWM
I am currently trying to program a batch script which allows the user to
I am currently trying to write functional tests for a charging form which gets
I'm currently trying to write a voicechat program in python. All tips/trick is welcome
I'm trying to write a program with a function which returns a matrix with
I'm trying to write a program in which a program continuously takes in a
I'm currently trying to build a simple component which should monitor, if the user
I'm trying to write a program which executes make.exe from MinGW distribution in the
I am currently trying to write a program to store data about people into
I am trying to write a C++ program which plays real-time processed audio. I

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.