Hi,
I am being failed by the system when verifying the below code for requirement - The min method must return the minimum of the numbers a, b, and c.
My result is
1
-3
3
5
I am unsure of where am I wrong in this. Arguments in the min function was pre-populated for the task.
Thank you.
package com.codegym.task.task02.task0216;
/*
Minimum of three numbers
*/
public class Solution {
public static int min(int a, int b, int c) {
//write your code here
int m = 0;
if (a <= b)
{
if (a <= c)
{
m = a;
}
}
else if (b <= c)
{
m = b;
}
else
{
m = c;
}
return m;
}
public static void main(String[] args) throws Exception {
System.out.println(min(1, 2, 3));
System.out.println(min(-1, -2, -3));
System.out.println(min(3, 5, 6));
System.out.println(min(5, 8, 10));
}
}