Ask Experts Questions for FREE Help !
Ask
    dookey's Avatar
    dookey Posts: 1, Reputation: 1
    New Member
     
    #1

    Jun 20, 2013, 12:52 PM
    ask java questions online for free
    The entry code for a room is 2 3 4. The user enters one digit at a time and may type in any number of wrong values, but as soon as the correct sequence is entered a „door open‟ message should be displayed. E.g. 2 5 2 3 4

    my loop stops looping after user enters one right entry code but I want it to keep looping until user enters 3 right entry code


    this is what I done so far


    Scanner input = new Scanner (System.in);

    int code1 = 2;
    int code2 = 3;
    int code3 = 4;
    int code = 0;



    for(int index = 0; code != code1 && code != code2 && code != code3; index++) {


    System.out.println("Enter code");
    code = input.nextInt();

    if ((code == code1) && (code == code2) && (code == code3)) {
    System.out.println("door open");
    }

    else if ((code != code1) && (code != code2) && (code != code3)) {
    System.out.println("wrong code");
    }

    }

Check out some similar questions!

Ask questions about pregnancy online for free [ 1 Answers ]

Hi I've had one round of ivf,and I'm due to do a test tomorrow to see if I'm pregnant,but me being me I just couldn't wait.so I done one this morning and it was positive. Is it to early to be happy or should I wait until tomorrow and see what the result is thank you xx

Ask java questions live free [ 1 Answers ]

I am having trouble with this question "Design and write an algorithm that will read a single word from the keyboard and prints to the screen whether this word is a palindrome or not. A palindrome is a word; (or sentence, but for this question we are only dealing with a single word); that is spelt...

Ask questions to gynecologist for free online [ 2 Answers ]

I am trying to conceive and my husband works out of state. This time he will be here during my fertile days, my fertile days are from August 21st-26th. Will I be able to conceive these days?


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.