input of value integer problem.

Discussion in 'Java' started by Jeremy, Feb 9, 2007.

  1. Jeremy

    Jeremy Guest


    > Hey, Sorry to bother you, I have output that is not doign what i want it
    > to
    > do. I'm just having trouble getting it to run the way I want it to do.
    > I'm
    > having trouble getting the first value read specific the number of value
    > to
    > input from the users....
    > here's the output of the program i got.
    > Indicate how many values you want to input:2
    >
    > Indicate numbers you want to calcuate for smallest integer:2
    > Press any key to continue...
    >
    >
    > import java.util.Scanner;
    > public class Input// public class name input
    >
    > {
    > public static void main (String args[])// main method to begine xecution
    > of
    > program
    > {
    > Scanner input = new Scanner(System.in);
    > int counter=1;// counter intialized to 1
    > int smallestnumber=0;//smallest number intialized to 0;
    > int values=0;// values intialized to 0;
    > int number=0; number is intialized to 0;
    >
    > {
    > System.out.printf("Indicate how many values you want to input:"); // ask
    > user
    > how many values you want to input and prompts you to do that.
    > values =input.nextInt();
    >
    > while ( counter<=values)// while statement that will count within values
    > {
    > System.out.println();
    > ++counter;
    > values=number;
    >
    > }
    >
    >
    > System.out.printf("Indicate numbers you want to calcuate for smallest
    > integer:");// ask what number you want to calcuate for the smallest
    > integer.
    > number =input.nextInt();
    > while (values==number)// this is not right statement anything
    > {
    > number=smallestnumber;
    > if (smallestnumber<=number)
    > {
    >
    > System.out.println(smallestnumber);
    > }
    > }
    >
    >
    >
    >
    >
    >
    > }
    > }

    }
    Jeremy, Feb 9, 2007
    #1
    1. Advertising

  2. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Jeremy schreef:
    >> Hey, Sorry to bother you, I have output that is not doign what i want it
    >> to
    >> do. I'm just having trouble getting it to run the way I want it to do.
    >> I'm
    >> having trouble getting the first value read specific the number of value
    >> to
    >> input from the users....
    >> here's the output of the program i got.
    >> Indicate how many values you want to input:2
    >>
    >> Indicate numbers you want to calcuate for smallest integer:2
    >> Press any key to continue...
    >>


    You didn’t formulate a question, but I’ll give some comments on your code:

    >>
    >> import java.util.Scanner;
    >> public class Input// public class name input
    >>
    >> {
    >> public static void main (String args[])// main method to begine xecution
    >> of
    >> program
    >> {
    >> Scanner input = new Scanner(System.in);
    >> int counter=1;// counter intialized to 1
    >> int smallestnumber=0;//smallest number intialized to 0;
    >> int values=0;// values intialized to 0;
    >> int number=0; number is intialized to 0;
    >>
    >> {
    >> System.out.printf("Indicate how many values you want to input:"); // ask
    >> user
    >> how many values you want to input and prompts you to do that.
    >> values =input.nextInt();
    >>
    >> while ( counter<=values)// while statement that will count within values
    >> {
    >> System.out.println();
    >> ++counter;
    >> values=number;
    >> }


    Since number is 0, values will be 0 after the first loop, which makes
    this code equivalent to:

    if (values >= 1) {
    System.out.println();
    counter = 2;
    values = 0;
    }

    That doesn’t seem to make any sense. Please reconsider.

    >>
    >>
    >> System.out.printf("Indicate numbers you want to calcuate for smallest
    >> integer:");// ask what number you want to calcuate for the smallest
    >> integer.
    >> number =input.nextInt();
    >> while (values==number)// this is not right statement anything


    values is 0, so it will only execute when the user entered 0.

    >> {
    >> number=smallestnumber;
    >> if (smallestnumber<=number)
    >> {
    >>
    >> System.out.println(smallestnumber);
    >> }
    >> }


    Have a look at the last link in my sig.

    H.
    - --
    Hendrik Maryns
    http://tcl.sfs.uni-tuebingen.de/~hendrik/
    ==================
    http://aouw.org
    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)

    iD8DBQFF0MZWe+7xMGD3itQRAudJAJ9xJBz0S4bKGAoOS3OM4Uqg6S1hcwCeLDDn
    gQH6viKCFhp7TTpzTv2YNgY=
    =HElQ
    -----END PGP SIGNATURE-----
    Hendrik Maryns, Feb 12, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    CType(x,Integer) vs. Integer.Parse(x)

    =?Utf-8?B?Sm9l?=, Feb 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,946
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Feb 7, 2006
  2. Robben
    Replies:
    14
    Views:
    559
    Old Wolf
    Dec 27, 2005
  3. Melissa
    Replies:
    2
    Views:
    606
    Gaurav Vaish \(a.k.a. MasterGaurav\)
    Dec 26, 2008
  4. chirs
    Replies:
    3
    Views:
    137
    Sergey I.Grachyov
    Oct 18, 2003
  5. Susan Cranford
    Replies:
    2
    Views:
    397
Loading...

Share This Page