Correct output result. But the last answer is not completed...
Code:
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) {
int i = (min(a, b));
if
(i <= c && a <= d)
i = i;
else if
(c <= i && c <= d)
i = c;
else
i = d;
return i;
}
public static int min(int a, int b) {
int z;
if
(a <= b)
z = a;
else
z = b;
return z;
}
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) {
int i = (min(a, b));
if
(i <= c && a <= d)
i = i;
else if
(c <= i && c <= d)
i = c;
else
i = d;
return i;
}
public static int min(int a, int b) {
int z;
if
(a <= b)
z = a;
else
z = b;
return z;
}
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));
}
}