+ 3
Why java compiler is not working well on sololearn
18 Antworten
+ 7
Your code is perfect Rowdy Reddy
I tried on ide and it works exactly as you want.
But as mentioned by Benjamin Jürgens in SL playground interactive input are not possible.
All your inputs should be given at once so the output will show for once only.
Users can only interact in web codes here.
+ 14
It's working 😅
Tell the input format
Like..
Input :
2
3
4
It will work
+ 10
Is it showing "Oops something went wrong"
+ 9
I'm lost now😅
Minho 🇰🇷 up to you 😅😆
+ 8
Yes then your code works fine..
+ 7
Can you please share your snippet
+ 7
The java. util. Scanner. nextInt() method Scans the next token of the input as an int.
So split inputs
https://code.sololearn.com/c17MEdH7wc5d/?ref=app
+ 4
Interactivity on sololearn is very limited. You have to provide all input first, one input per line.
Your program works if you provide 3 lines if input with numbers but obviously not as intended since the user can't react to the hints
+ 4
Thank you
+ 2
It is showing exception in thread main
+ 2
import java.util.*;
import java.util.Random;
public class Main {
public static void main(String[] args) {
int i,guess;
System.out.println("Guess a number between 0 an 10");
Random generator=new Random();
Scanner sc=new Scanner(System.in);
int r=generator.nextInt(11);
for (i=0;i<3;i++){
guess=sc.nextInt();
if (guess==r){
System.out.println("right");
break;
}
else if (guess<r){
System.out.println("too small");
}
else if (guess>10){
System.out.println("out of range");
}
else if(guess>r){
System.out.println("too big");
}
else{
System.out.println("invalid input");
}
}
}
}
+ 2
My java code is not working on sololearn but it is working on other apps why??
+ 2
Kk
+ 1
I wanted to give 3 chances in guessing
+ 1
It only asking the input once and giving error after that
0
try another
0
bug
0
It is an app not a command prompt that we use in computer or personal computer