i really need ur help guys.

hi guys.

can u please help me in my project?

i need a code for a java program that accepts input number and displays the largest among the individual digits of that input.

The sample output is here.

Input Number: 1234569822

Largest Digit: 9

We cant still use arrays guys because we didnt discuss it yet.

Hope u can help me with this.

for loop,while loop can do

thanks.

Re: i really need ur help guys.

Do you know how to find the least significant digit of a number? e.g. for the number 12345, the least significant digit is 5.

kind regards,

Jos

Re: i really need ur help guys.

my bad.

im really new to programming.

i dont really know.

hope u can help me

Re: i really need ur help guys.

Hint: It involves modulus and the base of the number format you are using...

Re: i really need ur help guys.

can u help me with the code?

im really new to java programming,

^_^

Re: i really need ur help guys.

What did you have completed? Do you know how modulus works?

I can help you with the code, but I'm not going to write it all for you.

Re: i really need ur help guys.

modulu sounds familiar but im going to check it.

i really need ur help with this because im failing this subject.

Re: i really need ur help guys.

Just break it down into more manageable sections. Rather then thinking about the entire project, think of it as four parts.

A)Gather input from the user

Using println() methods and the Scanner object.

B)Perform math on the user input

Using modulus (%), you can find the remainder.

C)Perform some type of comparison to find the largest single digit number

You could do this while doing the math, to save on variables, or save them all and do it later.

D)Output the answer to the user

Modulus is a tool that is used to find the remainder after a division occurs. Say you have 12/5, the answer would be 5 with 2 left over. If you used modulus, 12%5, the answer would be just the 2 left over. You can use this to find the least signigicant digit in a larger number. Say you have 25, and you wanted just the 5. Well since digits are base 10, you can just take the modulus of 25, 25%10, and you are just left with the 5.

Re: i really need ur help guys.

Now also appearing at javaprogrammingforums.com

@OP: If you are going to start a discussion in multiple places, please post links in each to the others. That way all the participants in the discussion know what else is being said.

And it is a discussion: questions, replies, comments, thoughts and reflections - all occurring in both directions. What it is *not* is a homework service. Not here, and not at javaprogrammingforums.

---

Have you thought about the problem? If so, it would be good to hear how you yourself (rather than a computer) would go about determining that 9 was the largest digit as you stated. Such a procedure (or algorithm) would form the basis of your code.

Look up the modulus or remainder operator (%) and find out how it relates to the least significant digit. Try and incorporate that into your algorithm (recipe) for determining the largest digit, and let us know how you get on.

Re: i really need ur help guys.

how about i want to input random numbers?

Re: i really need ur help guys.

import java.util.Scanner;

class group{

public static void main(String arng[]){

int value[]= new int[5];

int temp,i;

Scanner data = new Scanner(System.in);

System.out.println("Enter 5 element of array" );

// Enhanced for loop

for(i=0; i < 5; i++ ) value[i] = data.nextInt();

// finding Largest number

temp = value[0];

for(i=0; i < 5; i++ )

{

if(temp > value[i])

continue;

else

temp = value[i];

}

System.out.println("Largest number in array is "+temp);

}

}

Output:-

Enter 5 element of array

25

154

28522

218

2564

Largest number in array is 28522

i tried this but how can i do it without arrays?

and in a single 10 digits input how can i get the largest?

like 9899823211

how can i get 9?