Guest User

Untitled

a guest
Nov 19th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. package findposition;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class findposition {
  6.  
  7. public static void main(String[] args) {
  8. Scanner input=new Scanner(System.in);
  9.  
  10. int counter,num=0,max=0;
  11. counter=1;
  12.  
  13.  
  14.  
  15. while (counter<=10) {
  16.  
  17. System.out.println("Enter the "+counter+". number:");
  18. num=input.nextInt();
  19. counter++;
  20. }
  21.  
  22. max = Math.max(num, max);
  23. System.out.printf("Maximum value is %d",max);
  24.  
  25. }
  26. }
  27.  
  28. public int getIndexOfMaxValue( int[] array )
  29. {
  30. int maxIndex = 0;
  31. for ( int i = 1; i < array.length; i++ )
  32. {
  33. if ( array[i] > array[maxIndex] ) maxIndex = i;
  34. }
  35. return maxIndex;
  36. }
Add Comment
Please, Sign In to add comment