+ 5

Can you tell what is wrong with my code?

There is something wrong with my code. There are errors . Please help me find them. https://code.sololearn.com/cDpjYbfzznpT/?ref=app

10th Nov 2018, 10:51 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
13 Antworten
+ 12
// import Scanner import java.util.Scanner; import java.util.Random; and replace b in if statement with a!
10th Nov 2018, 11:10 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 11
Please, show us yours code so we can help you!
10th Nov 2018, 10:59 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 8
Mind To Machine 🤖😎 yes your right if the input its not greater or less then it will go to else 😉👍
11th Nov 2018, 8:39 AM
D_Stark
D_Stark - avatar
+ 6
Queen Arthur ,Brunnhilde [BUSY] ,Mind To Machine 🤖😎 ,Danijel Ivanović it was another lag. Here is the code. I am very sorry.
10th Nov 2018, 11:07 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 5
Danijel Ivanović I'll see tomorrow and see if I understand. Okay.
10th Nov 2018, 11:13 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 5
Mind To Machine 🤖😎 problem fixed! Thanks!
11th Nov 2018, 12:20 AM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 4
Brunnhilde [BUSY] what comma? You mean this ; ?
10th Nov 2018, 11:08 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 4
in the first if statement,where did you defined variable b?
10th Nov 2018, 11:11 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
+ 4
Danijel Ivanović I changed it but it still won't work....
10th Nov 2018, 11:11 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 4
Danijel Ivanović dunno what you mean....
10th Nov 2018, 11:13 PM
hi user, #Have_Hope
hi user, #Have_Hope - avatar
+ 3
can you post the code please?
10th Nov 2018, 10:56 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
+ 3
/* This will NOT work on the SoloLearn java IDE because of the infinite loop or only if your first guest is correct, so run on you own IDE */ import java.util.Scanner; import java.util.Random; public class Program { // edited by MindToMachine 7:15 Sat, November 10 2018 AST public static void main(String[] args) { Scanner sc = new Scanner(System.in); Random r = new Random(); int a = r.nextInt(10)+1; while (true) { //Guess and enter a number between 1 to 10 System.out.println("Guess A Number Between 1 And 10"); int c = sc.nextInt(); if(a>c) { System.out.print("The number is too small"); } if (a<c){ System.out.println("The number is too big"); } else { System.out.println("Congrats! Your guess is correct! Run this code again if you want to guess another number!"); break; } } } }
10th Nov 2018, 11:24 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
+ 2
D_Stark i think the else statement will handle the correct guest😎
10th Nov 2018, 11:47 PM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar