Results 1 to 5 of 5
  1. #1
    akocnivek is offline Member
    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0

    Default can u tell me w/c one is correct?

    im trying to figure out w/c one displays the largest number among the individual digits of my input.
    cuz im using windows now cant run them.

    Java Code:
    import java.util.Scanner;
    class Largest{
    public static void main(String args[]){
    Scanner x = new Scanner(System.in);
    int value = -1;
    int counter = 0;
    do{
    System.out.println(Enter an integer:");
    int tmp = x.nextInt();
    if (tmp > value)
    value = tmp;
    counter++;
    }while (counter < 5);
    System.out.println("Largest interger entered was >>" + value);
    }
    }

    this is the second one:


    Java Code:
    import java.util.Scanner;
    class Largest{
    public static void main(String args[]){
    Scanner i = new Scanner(System.in);
    int r = 0;
    int q = 0;
    int n = 0;
    int larger = 0;
    System.out.println("Enter input:");
    n = i.nextInt();
    for (q<10;){
    q = n/10;
    r = n%10;
    System.out.println("Quotient:" + q);
    System.out.println("Remainder:" + r);
    larger = Math.max(q, r);
    }
    System.out.println("The larger number is:" + larger);
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,301
    Rep Power
    20

    Default Re: can u tell me w/c one is correct?

    Quote Originally Posted by akocnivek View Post
    im trying to figure out w/c one displays the largest number among the individual digits of my input.
    What's w, and what's c? I don't see either as a variable name in your code. Not that the sentence makes any sense even if they did exist.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    akocnivek is offline Member
    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0

    Default Re: can u tell me w/c one is correct?

    i mean which one displays the largest number among the individual digits of my input.
    :D
    w/c = which

  4. #4
    romero4742 is offline Member
    Join Date
    Mar 2012
    Posts
    27
    Rep Power
    0

    Default Re: can u tell me w/c one is correct?

    both of them have syntax errors here's an online compiler, if you can't run it on your windows for some reason, Ideone.com | Online IDE & Debugging Tool >> C/C++, Java, PHP, Python, Perl and 40+ compilers and interpreters if you don't trust the link then google one...once you get the programs to work you can test both of them see which one works better for you
    Last edited by romero4742; 10-21-2012 at 09:01 AM. Reason: url correction

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,301
    Rep Power
    20

    Default Re: can u tell me w/c one is correct?

    Quote Originally Posted by akocnivek View Post
    w/c = which
    Please use proper words. This is a technical forum, not SMS chat.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Please help - can't seem to correct this...
    By jmjbreezin in forum New To Java
    Replies: 7
    Last Post: 05-09-2011, 01:39 PM
  2. Replies: 5
    Last Post: 06-08-2010, 04:22 PM
  3. Are my comments correct?
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-08-2010, 05:34 AM
  4. Syntax correct?
    By dbashby in forum New To Java
    Replies: 5
    Last Post: 09-22-2009, 06:44 AM
  5. Is this the correct Output?
    By Teny in forum New To Java
    Replies: 17
    Last Post: 04-13-2009, 12:52 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
  •