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 4 of 4

Thread: [Help] For Loops - Number Predicting Program

  1. #1
    Junior Member iAce's Avatar
    Join Date
    Dec 2012
    Location
    || ^_^ ||
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default [Help] For Loops - Number Predicting Program

    Hello, I need help with my code again. The steps below are the things I need in my code.

    1. The computer should randomly pick a three digit lottery number ranging from 000 through 999.
    2. Use a for loop to pick the single digit numbers, and concatenate them together to form a String.
    3. Prompt the user to enter a thee digit number (000 through 999).
    4. A number is winner if it matches the first two, the last two, or all three digits of the randomly chosen number.
    5. Notify the user whether they won or lost.

    How should I go about this code? I need to show that I can correctly use for loops. Any assistance would be great.


  2. #2
    Member
    Join Date
    Feb 2012
    Posts
    173
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: [Help] For Loops - Number Predicting Program

    you can use a for loop to:

    1. Generate a random number x amount of times.
    2. Loop through the items in an array, list, or arraylist.
    3. have the user input one number at a time
    4. check for equal values
    5. limit the amount of tries
    6. etc...

    Here are some ideas to get you going. The rest shouldn't be hard. Also, this belongs in the Java Theory board.

  3. The Following User Says Thank You to aesguitar For This Useful Post:

    iAce (December 12th, 2012)

  4. #3
    Junior Member iAce's Avatar
    Join Date
    Dec 2012
    Location
    || ^_^ ||
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: [Help] For Loops - Number Predicting Program

    Quote Originally Posted by aesguitar View Post
    you can use a for loop to:

    1. Generate a random number x amount of times.
    2. Loop through the items in an array, list, or arraylist.
    3. have the user input one number at a time
    4. check for equal values
    5. limit the amount of tries
    6. etc...

    Here are some ideas to get you going. The rest shouldn't be hard. Also, this belongs in the Java Theory board.
    Okay thank you. That'll be a start. I kind of have an idea of how to do this now. Why does this belong in the Java Theory board? Because it's Java lol? Or because I don't actually have a code to start off with?

  5. #4
    Member
    Join Date
    Feb 2012
    Posts
    173
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: [Help] For Loops - Number Predicting Program

    It belongs in Theory because it does not have any errant code, let alone code period. It's called What's wrong with my Code because you can't figure out what's wrong with the code you have.

Similar Threads

  1. Replies: 10
    Last Post: November 8th, 2012, 06:29 AM
  2. Replies: 4
    Last Post: September 6th, 2012, 05:29 AM
  3. Finding the Two-Thirds Root of a Number Using Loops
    By tryingtolearn in forum Loops & Control Statements
    Replies: 4
    Last Post: July 8th, 2012, 08:44 PM
  4. Creating number Pyramids with For Loops
    By Staticity in forum Loops & Control Statements
    Replies: 3
    Last Post: October 2nd, 2011, 05:20 PM
  5. Replies: 4
    Last Post: June 10th, 2009, 01:04 AM