if the user enter wrong number the program doesn't ask him for another try so how could l fix it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

if the user enter wrong number the program doesn't ask him for another try so how could l fix it

http://www.sololearn.com/app/java/playground/cXMbS5SbTEmN/

17th Feb 2020, 5:11 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
9 Answers
17th Feb 2020, 5:44 PM
Avinesh
Avinesh - avatar
0
You want the program to ask the user again or not? Also share the code so that we can understand your situation.
17th Feb 2020, 5:15 PM
Avinesh
Avinesh - avatar
0
i shared the code link you could take a look and here is the code link again http://www.sololearn.com/app/java/playground/cXMbS5SbTEmN/
17th Feb 2020, 5:16 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
0
The link leads to the sololearn app in play store.
17th Feb 2020, 5:18 PM
Avinesh
Avinesh - avatar
0
how ? it's must lead you to my code on the playground
17th Feb 2020, 5:20 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
0
Would you mind copy pasting the code here because I really cannot reach it.
17th Feb 2020, 5:34 PM
Avinesh
Avinesh - avatar
0
import java.util.Scanner; public class Javagame { public static void main(String[] args) { Scanner input = new Scanner(System.in); int guess ,rand; rand =(int) (Math.random ()*10) ; boolean stillplaying = true; for(int i=1 ;i<=10;i++){ if(i==rand) { continue; } System.out.println(i); } System.out.println("try to fined the missed number between 1 and 100"); guess = input.nextInt(); if(guess>10|| guess<=0) System.out.println("out of range"); else if (guess!=rand&& guess>0&& guess<=10 ) System.out.println("you are wrong dude"); else if(guess==rand) { System.out.println("You Win"); stillplaying = false; } } }
17th Feb 2020, 5:37 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
0
oh i forget while(stillplaying) thank you alot dude ❤️
17th Feb 2020, 5:49 PM
Mahmoud Hamed
Mahmoud Hamed - avatar
0
Mahmoud Hamed you're welcome👍
17th Feb 2020, 5:50 PM
Avinesh
Avinesh - avatar