import java.util.Scanner;

class M6                                   //Main Method
{
public static void main(String args[])     //Index of Largest Number method

{
int a[];
int i;
a= new int[10];
System.out.print("Enter any 10 numbers:");
Scanner s = new Scanner(System.in);
a[0]=s.nextInt();
a[1]=s.nextInt();
a[2]=s.nextInt();
a[3]=s.nextInt();
a[4]=s.nextInt();
a[5]=s.nextInt();
a[6]=s.nextInt();
a[7]=s.nextInt();
a[8]=s.nextInt();
a[9]=s.nextInt();

System.out.println("The 10 no.'s you have entered are: ");
for(i=0;i<10;i++)
{
System.out.print("  "+a[i]);
}

double b=a[0];

for(i=0;i<10;i++)
{
	if(a[i]>b)
	{
	 b=a[i];
	}
}
System.out.println("The greatest amoung 10 is "+a[i]);
}

}

this is the program i made plz tell me where i m wrong.....

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

What is the problem? Do you get errors?
Is the output wrong?

Please post the output to show what is wrong.

What is the purpose of the variable b?

import java.util.Scanner;

class M6{
	public static void main(String args[]){

		int[] a = new int[10];
		Scanner s = new Scanner(System.in);

		for(int i=0;i<10;i++){
			System.out.print("Enter a["+i+"]: ");
			a[i] = s.nextInt();
		}

		System.out.println("Here it is your array: ");
		for(int i=0;i<10;i++)
			System.out.print("a["+i+"]: " + a[i] + "\n");
		
		int max = a[0];
		for(int i=1;i<10;i++)
			if(a[i] > max)
				max = a[i];

		System.out.println("The Maximum Value of array is " + max);
	}

}

Edited 5 Years Ago by imyself: Added code tags. Please use them to format any code that you post.

Comments
Completing homework for others is not acceptable.

Posting complete homework solutions is discouraged here. We are here to help people solve their own problems and learn. We are not a homework completion service.

Sharing ideas is good, but try to use examples, hints or explanations to guide them to the solution rather than writing the exact code for them.

Edited 5 Years Ago by Ezzaral: n/a

You are able to edit posts within 30 minutes of submitting them, if that is what you are asking.

There is an "Edit" button next to the post.

It should be a big deal for me. To tell the truth, i'm just dunno how to explain or hint to people. so what should i do next?

This article has been dead for over six months. Start a new discussion instead.