Where is my problem ? i dont get it . Pls help me /: last print will turn into "0" every time
package de.codegym.task.task02.task0217;
/*
Die kleinste aus vier Zahlen
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
int m = 0;
min(a, b);
if (c <= a && c <= b && c <= d)
{
m = c;
}
else if (d <= a && d <= b && d <= c)
{
m = d;
}
return m;
}
public static int min(int a, int b) {
int n = 0;
if (a <= b)
{
n = a;
}
else if (b <= a)
{
n = b;
}
return n;
}
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 de.codegym.task.task02.task0217;
/*
Die kleinste aus vier Zahlen
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
int m = 0;
min(a, b);
if (c <= a && c <= b && c <= d)
{
m = c;
}
else if (d <= a && d <= b && d <= c)
{
m = d;
System.out.println(m);
}
return m;
}
public static int min(int a, int b) {
int n = 0;
if (a <= b)
{
n = a;
}
else if (b <= a)
{
n = b;
}
return n;
}
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));
}
}