import java.util.Scanner;
public class fmax
{
public static void main(String[] args)
{
int max;
max = maxnum();
System.out.println("The max number is: " + max);
}
public static int maxnum()
{
int max = 0, element = 0;
Scanner keyboard = new Scanner(System.in);
int []fmax = new int[10];
for(int i = 0; i < fmax.length; i++)
{
System.out.print("Enter number " + (i+1) + ":");
fmax[i] = keyboard.nextInt();
if(fmax[i] > max)
{
max = fmax[i];
element = i; //the variable i want to be returned
}
}
return max;
}
}
Okay, I am able to return a max value in this program, however, I would like to return the value of the element/index assigned to the max value that I return. How would i go about doing that?