So this program returns "Minimum = -79" but does not pass the following two requirements.
1. "The class must have a public static min method that takes 5 int arguments."
2. "The min method must return the minimum of the 5 passed numbers. If there are several minimum numbers, return any of them."
Could someone please explain to me what is wrong with my code?
Thank you :)
package com.codegym.task.task05.task0531;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Improving functionality
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int y =Integer.parseInt(reader.readLine());
int x =0;
for(int i=1;i!=5;i++){
x =Integer.parseInt(reader.readLine());
y =min(y,x);
}
System.out.println("Minimum = " + y);
}
public static int min(int a, int b) {
return a < b ? a : b;
}
}
/*original:
package com.codegym.task.task05.task0531;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int minimum = min(a, b);
System.out.println("Minimum = " + minimum);
}
public static int min(int a, int b) {
return a < b ? a : b;
}
}
*/