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 minimum;
int e= min(a,b);
if(c<=d && c<=e)
{
minimum = c;
}else
{
minimum =d;
}
return minimum;
}
public static int min(int a, int b) {
int min;
if(a<b)
min=a;
else
min=b;
return min;//write your code here
}
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));
}
}
Write a function that computes the minimum of four numbers. The function min(a, b, c, d) should use (call) the function min(a, b)
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
14 May 2019, 13:57
You code only has 2 possible answers, either 'c' or 'd'. That will not work if the minimum is 'a' or 'b'.
0
sailaja
14 May 2019, 13:32
Can some one help me on this The min(a, b, c, d) method must return the minimum of the numbers a, b, c, and d. its not passing the test case.Kindly assist
0