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.out.println("The 10 no.'s you have entered are: ");
System.out.print("  "+a[i]);

double b=a[0];

System.out.println("The greatest amoung 10 is "+a[i]);


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

Recommended Answers

All 10 Replies

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(;

		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);

commented: Completing homework for others is not acceptable. -3

Hope this can help you...

commented: Too much spoon feeding -3

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.

Sorry... I didn't mean to solve the problem, though i just wanted to share idea.

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.

don't it have any chances for me to make it right?

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.