I'm trying to find out why I'm getting an error compiling my code. It should be finding the maximum and minimum of the variables entered in the for loops. I know the code is redundant, but it's for a class.
import java.util.*;
public class ForInputNumbers
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
int value1=0,value2=0,value3=0,value4=0,value5=0;
System.out.println("Please type a number");
for (; value1==0;System.out.println("Please type the next number"))
{
value1 = input.nextInt();
}
for (; value2==0;System.out.println("Please type the next number"))
{
value2 = input.nextInt();
}
for (; value3==0;System.out.println("Please type the next number"))
{
value3 = input.nextInt();
}
for (; value4==0;System.out.println("Please type the next number"))
{
value4 = input.nextInt();
}
for (; value5==0;System.out.println("Please type the next number"))
{
value5 = input.nextInt();
}
System.out.println("Your numbers: "+value1+" "+value2+" "+value3+" "+value4+" "+value5);
System.out.println("The sum of your numbers: "+(value1+value2+value3+value4+value5));
System.out.println("The average of your numbers: "+(value1+value2+value3+value4+value5)/5);
System.out.println("The largest of your numbers: "+(Math.max(value1,value2,value3,value4,value5)));
System.out.println("The smallest of your numbers: "+(Math.min(value1,value2,value3,value4,value5)));
}//end main method
}//end class
My errors:
ForInputNumbers.java:60: error: no suitable method found for max(int,int,int,int,int)
System.out.println("The largest of your numbers: "+(Math.max(value1,value2,value3,value4,value5)));
^
method Math.max(int,int) is not applicable
(actual and formal argument lists differ in length)
method Math.max(long,long) is not applicable
(actual and formal argument lists differ in length)
method Math.max(float,float) is not applicable
(actual and formal argument lists differ in length)
method Math.max(double,double) is not applicable
(actual and formal argument lists differ in length)
ForInputNumbers.java:62: error: no suitable method found for min(int,int,int,int,int)
System.out.println("The smallest of your numbers: "+(Math.min(value1,value2,value3,value4,value5)));
^
method Math.min(int,int) is not applicable
(actual and formal argument lists differ in length)
method Math.min(long,long) is not applicable
(actual and formal argument lists differ in length)
method Math.min(float,float) is not applicable
(actual and formal argument lists differ in length)
method Math.min(double,double) is not applicable
(actual and formal argument lists differ in length)
2 errors
Any help is appreciated, thanks.