Я пытаюсь выяснить, почему я получаю ошибку при компиляции моего кода. Он должен найти максимум и минимум переменных, введенных в циклы for. Я знаю, что код лишний, но для класса.Найти максимум Ошибка: не найдено подходящего метода для max (int, int, int, int, int)
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
Мои ошибки:
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
Любая помощь приветствуется, спасибо.
Прочитайте сообщение об ошибке перед отправкой пожалуйста – Natecat
Что такая точкой для петель? – Natecat
@natecat Я упомянул, что это было для задания, что оно было избыточным и т. Д. –