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

    Default do-while,, help me out pls

    can u help me out with this?
    a program that accepts input no. and dsplays the largest among the individual digit of that input?\
    cant detect errors.
    please help.

    import java.io.*;
    import java.util*;
    class Largest{
    public static void main(String args[]){
    Scanner x = new Scanner(System.in);
    int temp,j = 0;
    do{
    System.out.println("Enter the number:");
    int num = x.nextInt();
    String s = " " + num;
    int i = 0;
    while (i < s.lenght){
    System.out.println(s.charAt(i));
    int in = s.charAt(i);
    if (in<=j){
    temp = in;
    }
    else{
    temp = j;
    }
    }
    System.out.println("The largest digit is" + largest);
    }
    }

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

    Default Re: do-while,, help me out pls

    this is my second attemp guys.


    import java.util.Scanner;
    class Kevin{
    public static void main(String args[]){
    Scanner i = new Scanner(System.in);
    int largest = 0;
    int largest;
    {
    System.out.println("Enter the number:");
    remainder = 0%10;
    if (remainder > largest);
    largest = remainder;
    else
    System.out.println("The largest digit is" /10);
    }
    }

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

    Default Re: do-while,, help me out pls

    Quote Originally Posted by akocnivek View Post
    this is my second attemp guys.
    Java Code:
    int largest = 0;
    int largest;
    }
    you cannot create two variables with the same name

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

    Default Re: do-while,, help me out pls

    Also use code tags for your code it makes it easier to read

Posting Permissions

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