Four tired cowboys sat in a room. Each of them has to draw a number out of a pot. Whoever of the four draws the smallest number has to go fetch some whiskey. Help these guys determine who has to go. Find the minimum of the four numbers.
Minimum of four numbers
- 7
Locked
Comments (62)
- Popular
- New
- Old
You must be signed in to leave a comment
sugiharto Singodimejo
11 February, 21:33
i use chat gpt
public static int min(int a, int b, int c, int d) {
//write your code here
int minab = min(a,b);
int mincd = min(c,d);
return min(minab,mincd);
}
public static int min(int a, int b) {
//write your code here
return a < b ? a : b;
0
Nandini
13 September 2021, 17:28
I am getting this error. can anyone help me please?
com/codegym/task/task02/task0217/Solution.java:41: error: unreachable statement
return 0;
0
John Squirrels Website Admin at CodeGym
14 September 2021, 14:33
Please send us a DM.
+1
Yusuf el Turki
18 May 2021, 05:38
I got the correct output but i got these Warnung. I dont understand why is that so,
What means same method? I have got 2 different if method wrote.
![]()

0
John Squirrels Website Admin at CodeGym
20 May 2021, 10:09
Yusuf, please create a question regarding this task in HELP section and send us a link. Our devs will be happy to assist you with the task.
0
Zoee
12 August 2021, 21:33
Create an object for your function.
Int e= min(a,b);
Then search for the smallest value
And when your stuck check out the Community help functie.
+3
Eros nullfeathers
23 March 2021, 05:10
I just had an observation. Since the methods are public and using the same int a, b and for the other method c and d; Does it mean it is using the same variable if we use the 2 variable method inside the 4 variable method? Its obvious that yest this is true but I just wanted someone to confirm my "theory". I think this is a true observation as the methods are public and therefore able to share the 2 variables amongst each other.
0
Java_Mooood
16 October 2020, 17:34
It easy ,
-use the previous task(Minimum of three numbers )
-Call min(a,b) from the min(int a, int b, int c, int d) method to fix the overloading error that Intellj might display .
-use if and if esle , else ..
0
fiskaren
7 October 2020, 15:09
I had completed all the requirements in my program except for "The min(a, b, c, d) method must use the min(a, b) method.". So I looked for help and found out to put in "int min1 = min(a,b);" in the "min(a,b,c,d)" function and it passed the requirements. I am not sure if it's the correct way of solving this task because I think they wanted me to actually use this line of code more.
+1
Roman
12 October 2020, 06:11
for example, you need to use the perimeterOfSquare method, which should calculate the perimeter of a square.
Correct version:
Wrong version:
Output is the same, but ... +1
Sebastian
29 September 2020, 15:53
Help please, the result seem to give me the minimum of all the numbers but i can't pass the test. any help pls?
+2
Roman
2 October 2020, 06:03
Please post your question with the attached solution in the section Help.
0
Lorenzo Cammerinesi
22 September 2020, 08:10
Quite frustrated I found this task really easy, I solved it in three different ways on eclipse without problems instead here the task can't be accepted.In all 3 compilation I always respected what was requested and still I can't pass the task. I start to think that the program pretend exactly the writing that was saved in it so at this point is all about fortune to get it. I'm concern about the future tasks when stuff start to be harder.
+2
Kasia
18 September 2020, 11:00
Hi, I got the right output (the min number for each method) but the test failed on the last statement: The min(a, b, c, d) method must return the minimum of the numbers a, b, c, and d >.> If anybody could explain why that would be wonderful and very useful to me :)
![]()

+1
Roman
22 September 2020, 06:31
Because tests use different data
0
Shreedhar D Joshi
6 April 2020, 14:20
how can i solve this plz help
0