what are the errors in this given code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what are the errors in this given code ?

public class practice1 { public static void main (String []asr){ Scanner s=new Scanner(System.in); int x=s.nextInt(),cube=0,unit=0; cube=x*x*x; practice1.method1(cube); public int method1(int a){ if(a%10<10) { if((a%10)==(method2(x))) //Is x not a global variable ? { return a; } else{ System.out.println("Not that no"); } } else { int cube = a%10; method1(cube); } public int method2(int s){ if(s%10<10) { return s%10; } else { int no=s%10; method2(no); } } }

20th Sep 2018, 5:15 AM
Rishabh Kaushik
Rishabh Kaushik - avatar
2 Answers
+ 2
I noticed you use Scanner but didn't have "import java.util.Scanner;" other than that missing curly brackets, and method1 & method2 being non-static. What do you want to do with this code? are you attempting the trimorphic number challenge? (I see you use cube). Provide more information please.
22nd Sep 2018, 6:57 AM
Ipang
+ 1
Ipang yes, you are right. I’m trying to attempt trimorphic challenge. I resolved the errors now !but still getting issues in return in methods !!? I’ll share the code again
22nd Sep 2018, 8:22 AM
Rishabh Kaushik
Rishabh Kaushik - avatar