What's wrong with this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's wrong with this code?

Here's the code:import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int inpu=NextInt(); int shin=NextInt(); int han=shin+1; double puh=Math.pow(shin,han); if(inpu=puh){System.out.println("congrats");}else{System.out.println("incorrect");}} }

29th Nov 2023, 11:25 AM
daniel
4 Answers
+ 7
First, it would be more easier for people to try your code, if you save it in the code playground, and insert a link here. On quick inspection, you are taking input incorrectly. NextInt() is not valid on its own. The scanner object you created, has a nextInt() method. Pay attention to lowercase and uppercase letters too. int inpu = sc.nextInt();
29th Nov 2023, 11:50 AM
Tibor Santa
Tibor Santa - avatar
0
Try it before giving it to me
29th Nov 2023, 11:26 AM
daniel
0
Ok I tried that and made a few other changes but it says I am converting a long into an int hers the code:import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int fruit = input.nextInt(); int carter=fruit/2/3; double carte=Math.floor(carter); int cartee=Math.round(carte); System.out.println(cartee); } }
2nd Dec 2023, 5:43 AM
daniel
0
I don't even know what a long is
2nd Dec 2023, 5:44 AM
daniel