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) {
//write your code here
this.min(a,b);
int a1 = (<int a, int b>);
int a2 = 0;
int a3;
if (c<=d)
{
a2 = c;
}
else
{
a2 = d;
}
if answer1 <= a2{
(return a1);}
else if return {a2;}
}
}
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));
}
}
public static int min(int a, int b) {
//write your code here
int a1=1;
if (a<=b)
{a3 = a;} //20
else
{a3 = b;}
return a3;
}
Below is my code: I just can't get it. I'm missing something help please!
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
13 February 2019, 15:01
Are you using IntelliJ? If not then you should be. There are multiple syntax errors that intelliJ would point out to you. At this point it would be best to rest the solution and start over. Keep it simple.
#1 solve how to return the minimum of 2 numbers inside the min(int a, int b) function.
#2 use the solve in #1 and apply it to returning the minimum of 4 numbers. This is easy as you have to find the minimum of the first two, then the minimum of the last 2, and then the minimum of the results of those.
I recommend looking up 'methods' and 'variable scope', both apply to this task.
https://www.w3schools.com/java/java_methods.asp <- method tutorial
https://www.java-made-easy.com/variable-scope.html <- variable scope
0
Jeff Jeffy
18 February 2019, 23:50
Yeah but CodeGym tasks on IntelliJ don't seem to be working.
Before every CodeGym task it says
import java.io*;
to import tools blah blah blah, which you already know, seeing as to how you're level 20.
However, this has a "syntax error" which it gladly points out to me.
0
Kim Ledford Wilson
13 February 2019, 14:47
what am I missing guys?
0