Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Lotto program for intro to programing final

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Lotto program for intro to programing final

    I have my program working except for one part.
    I have to determine if 2 of the 3 random generated numbers match 2 of the 3 user input numbers.
    I have copied in just that part of the code and not the whole program.
    What happen if I have just one number match it says that 2 do.
    Any help would be appreciated.
    Thanks

    else if (lotteryDigit1 == guess1
               || lotteryDigit1 == guess2
               || lotteryDigit1 == guess3
               && lotteryDigit2 == guess1
               || lotteryDigit2 == guess2
               || lotteryDigit2 == guess3
               && lotteryDigit3 == guess1
               || lotteryDigit3 == guess2
               || lotteryDigit3 == guess3)                                    
     
          System.out.println("Two numbers match: you win $1,000");


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Lotto program for intro to programing final

    What happen if I have just one number match it says that 2 do.
    Looks like you are testing for three matching numbers and printing "Two numbers match"

Similar Threads

  1. Programing
    By goha14 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 27th, 2012, 04:44 PM
  2. help with a programing assignment.
    By oscar_m in forum Object Oriented Programming
    Replies: 4
    Last Post: May 1st, 2011, 02:00 PM
  3. Loopy Lotto....
    By JavaCow in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 18th, 2010, 06:28 PM
  4. new program (lotto.class)
    By james137 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 3rd, 2009, 04:22 PM
  5. final class, final <variable> or <data member>
    By chronoz13 in forum Object Oriented Programming
    Replies: 9
    Last Post: September 20th, 2009, 08:19 AM