plz help me how to make this code that accepts 10 integers and display the largest.thanks in advance ...hoping for your positive responds

Scanner scn = new Scanner(System.in);
int i = 0;

if (scn.hasNextInt()) 
  i = scn.nextInt();

That is for reading from keyboard. Read the first number and assume that it is the max:

Scanner scn = new Scanner(System.in);
int num = 0;
int max = 0;

  num  = scn.nextInt();

max = num ;

Then read the rest of the numbers,but, Every time you read a number compare it with "max". If that "number" is greater than "max", it means the new number is the largest so replace the old value of "max" with the new:

if (number>max) {
  max = number;
}

thanks for the code...it helps me....

Be a part of the DaniWeb community

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