Attached is my solution. I've met all requirements and my outputs are the minimum of the set of these numbers. I've called to the method and still failed the:
• The "min(a, b, c, d) method must return the minimum of the numbers a, b, c, and d." task
-----------------
package com.codegym.task.task02.task0217;
/*
Minimum of four numbers
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
//write your code here
int x = min(a,b);
int min2;
if (x <= c && x <= d)
min2 = a;
else if (x <= c && x <= d)
min2 = b;
else if (c <= x && c <= d)
min2 = c;
else
min2 = d;
return min2;
}
public static int min(int a, int b) {
//write your code here
int min2;
if (a < b)
min2 = a;
else
min2 = b;
return min2;
}
public static void main(String[] args) throws Exception {
System.out.println(min(-20, -10));
System.out.println(min(-20, -10, -30, -40));
System.out.println(min(-20, -10, -30, 40));
System.out.println(min(-40, -10, -30, 40));
}
}
package com.codegym.task.task02.task0217;
/*
Minimum of four numbers
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
//write your code here
int x = min(a,b);
int min2;
if (x <= c && x <= d)
min2 = a;
else if (x <= c && x <= d)
min2 = b;
else if (c <= x && c <= d)
min2 = c;
else
min2 = d;
return min2;
}
public static int min(int a, int b) {
//write your code here
int min2;
if (a < b)
min2 = a;
else
min2 = b;
return min2;
}
public static void main(String[] args) throws Exception {
System.out.println(min(-20, -10));
System.out.println(min(-20, -10, -30, -40));
System.out.println(min(-20, -10, -30, 40));
System.out.println(min(-40, -10, -30, 40));
}
}