Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By JosAH

Thread: how to set a user controlled loop

  1. #1
    asilva1818 is offline Member
    Join Date
    Jan 2015
    Location
    California
    Posts
    2
    Rep Power
    0

    Default how to set a user controlled loop

    I am new to java and could use some help. here is my problem to solve

    Find the smallest value Write an application that finds the smallest of several integers. Assume that the first value read specifies the number of values to input from the user.

    I do not even know where to begin other than creating a scanner for the user input. But how do I take that user inputed number to create the loop?

    Thanks!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: how to set a user controlled loop

    Can you create a loop that iterates (i.e. 'loops') 10 times? Can you create a loop that iterates 'n' times? Can you ask the user for a value of 'n'?

    kind regards,

    Jos
    DarrylBurke likes this.
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    chanhjdev is offline Member
    Join Date
    Jan 2015
    Posts
    8
    Rep Power
    0

    Default Re: how to set a user controlled loop

    You can catch event that use inputed character. example word 'X' etc....

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,716
    Rep Power
    18

    Default Re: how to set a user controlled loop

    You can catch event ...
    I don't think an event driven application is wanted here.

    @OP: You say you can create a scanner. That's the first step. Then use one of the Scanner methods to read the first int. Finally, as Jos suggests, use that int to control a loop that reads the other values.

    You might want to think about what sort of loop it should be. It is significant that you know in advance how many times the loop should loop. (It's the number you read first with the scanner.)

    To begin with don't worry too much about the content of the loop. First make sure you can read the initial number with the scanner, and then use the loop to read the other values. After that you can worry about what else should go in the loop.

  5. #5
    asilva1818 is offline Member
    Join Date
    Jan 2015
    Location
    California
    Posts
    2
    Rep Power
    0

Similar Threads

  1. having issue with user input and using while loop
    By barqcider in forum New To Java
    Replies: 4
    Last Post: 10-09-2012, 02:06 AM
  2. User-Controlled Tree Edges
    By robbie.26 in forum AWT / Swing
    Replies: 4
    Last Post: 07-03-2011, 07:21 AM
  3. While loop comparing strings from user
    By N3VRMND in forum New To Java
    Replies: 5
    Last Post: 10-30-2009, 09:18 AM
  4. [SOLVED] User Input - loop
    By new person in forum New To Java
    Replies: 4
    Last Post: 02-22-2009, 11:02 PM
  5. loop when there is no user-input
    By becky in forum New To Java
    Replies: 12
    Last Post: 02-02-2009, 11:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •