What's wrong with my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
16th Nov 2021, 9:39 AM
Ananya | Inactive |
Ananya | Inactive | - avatar
5 Answers
+ 4
//See this public class Program { public int input(int x, int y, int z) { int small = 0; if (x < y && x < z) small = x; else if ( y < x && y < z) small = y; else if ( z <x && z < y) small = z; return (small ); } void show() { int small_no; int m = 2, n = 3, o = 5; small_no = input(m,n,o); System.out.println("The smallest from "+m+","+n+" and "+o+" is "+small_no); } public static void main(String args[]) { Program p=new Program(); p.show(); } }
16th Nov 2021, 9:51 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Because u missing main function you need to write main function inside main function body u can call show function ()
16th Nov 2021, 9:48 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 3
Oh thanks But would it will be my silly mistake
16th Nov 2021, 9:51 AM
Ananya | Inactive |
Ananya | Inactive | - avatar
+ 2
You have to define "main" function, and then call other functions (such as input() and show() ) in its body. public static void main(String[] args) { //call your functions here } Now you are not calling your functions.
16th Nov 2021, 9:49 AM
Morteza Hajji
0
https://www.sololearn.com/discuss/1538147/?ref=app You should be first master the concept's of if else if and if statement. Refer these for revision... And check your Java course too Hope it works... Happy coding.... (*Joking answer)
17th Nov 2021, 9:27 AM
𝓐𝓷𝓼𝓱𝓲𝓴𝓪 (Anshika)
𝓐𝓷𝓼𝓱𝓲𝓴𝓪 (Anshika) - avatar