Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package findposition;
- import java.util.Scanner;
- public class findposition {
- public static void main(String[] args) {
- Scanner input=new Scanner(System.in);
- int counter,num=0,max=0;
- counter=1;
- while (counter<=10) {
- System.out.println("Enter the "+counter+". number:");
- num=input.nextInt();
- counter++;
- }
- max = Math.max(num, max);
- System.out.printf("Maximum value is %d",max);
- }
- }
- public int getIndexOfMaxValue( int[] array )
- {
- int maxIndex = 0;
- for ( int i = 1; i < array.length; i++ )
- {
- if ( array[i] > array[maxIndex] ) maxIndex = i;
- }
- return maxIndex;
- }
Add Comment
Please, Sign In to add comment