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 (54)

- Popular
- New
- Old

You must be signed in to leave a comment

Eros nullfeathers

23 March, 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

vigvu

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.

0

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?

0

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.

0

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 :)

0

Roman

22 September 2020, 06:31

Because tests use different data

0

Sean Walker

14 March 2020, 03:55

I'm stuck on this one... I've looked up alternative tutorials on overloading methods and I am still not getting how to put all the pieces together... does anyone got a good tutorial on overloading methods? I'm not looking for the answer to the task, I want to learn this and understand this.

0

olik09

3 April 2020, 07:20

Start with the second min function. The second function will return to you the min which is a or b and will print when it's called in the main function. For the first min, you need to call the second function to do the same thing for int a and b. You can do that by typing:

now "whatever" is the min of int a and int b. Now, use it to get the min of the three variables, "whatever", c and d.
Then, let the function return to you the smallest of these and you're done. +2

HaeWon Chung

11 January 2020, 04:18

I think the real take home message of this task is that even if method names are same, java will consider them as different methods if the number of arguments (I guess types as well) are different.

+2

Timothy Strong

17 October 2019, 12:23

What does min(a,b,c,d) method use min(a,b) method mean?

+1

Timothy Strong

17 October 2019, 12:47

Got inside from fellow coder..thanks guyz!

+2

Sacha

12 October 2019, 19:09

What is the meaning of calling the min function with two argumentes from the function with 4 argumentes?

+2

hidden #10568956

18 December 2019, 12:37

You can compere a > b in the

method and then store it in to a variable like this and you can use to do stuff with it ( you will have somthing like 3 letters to compare instead of 4) +4

Brandon

3 May 2020, 19:01

Could not remember how to use the answer out of min(a, b). Read this and was like OH DUH!

+1

Rica

20 April, 01:26

This helped me a lot. Thank you!

0