import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); String stroka2; do{ System.out.println("Опять блядские тесты, играем? y/n?"); String stroka = scn.next(); if (stroka.equals("y")) { System.out.println("Теперь введите какое нибудь число, которое будет чуть больше 110ти"); int chislo = scn.nextInt(); if (chislo > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); String stroka2 = scn.next(); if(!stroka2.equals("Андрей")){ System.out.println("Приятно познакомиться " + stroka2 + ", а меня зовут Жора"); } } else { System.out.println("Ты тупой или че? Еще раз пытайся"); int chislo2 = scn.nextInt(); if (chislo2 > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); String stroka2 = scn.next(); if(!stroka2.equals("Андрей")) { System.out.println("Приятно познакомиться " + stroka2 + ", а меня зовут Жора"); } } else { System.out.println("Ебать может все таки сделаешь о чем я прошу?????"); int chislo3 = scn.nextInt(); if (chislo3 > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); String stroka2 = scn.next(); if(!stroka2.equals("Андрей")) { System.out.println("Приятно познакомиться " + stroka2 + ", а меня зовут Жора"); } } } } }else if(stroka.equals("n")){ System.out.println("ой ебать иди нахуй"); } else{ System.out.println("у тебя два варианта даунич"); } }while(stroka2.equals("Андрей")); } } Closed due to the fact that off-topic participants 0xdb , Enikeyschik , aleksandr barakin , freim , Kromster 15 May at 11:59 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - 0xdb, freim
- There is such a code, the problem is in the very last line. stroka2, stroka3.stroka4 are highlighted in red, and the idea says no resolve symbol. I tried a simple while loop without a do, the result is the same, while it doesn’t seem to see the user input strings what am i doing wrong? - jewbaka
- oneThe problem is a lack of understanding of scopes. You refer to variables that are not yet declared. - Sergey Gornostaev
2 answers
In short, here is the answer.
public static void main(String arr[]){ Scanner scn = new Scanner(System.in); String userAnswer; int userNumber; do{ System.out.println("Опять блядские тесты, играем? y/n?"); userAnswer = scn.nextLine(); if (userAnswer.equals("y")) { System.out.println("Теперь введите какое нибудь число, которое будет чуть больше 110ти"); userNumber = scn.nextInt(); if (userNumber > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); userAnswer = scn.nextLine(); if(!userAnswer.equals("Андрей")){ System.out.println("Приятно познакомиться " + userAnswer + ", а меня зовут Жора"); } } else { System.out.println("Ты тупой или че? Еще раз пытайся"); userNumber = scn.nextInt(); if (userNumber > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); userAnswer = scn.nextLine(); if(!userAnswer.equals("Андрей")) { System.out.println("Приятно познакомиться " + userAnswer + ", а меня зовут Жора"); } } else { System.out.println("Ебать может все таки сделаешь о чем я прошу?????"); int chislo3 = scn.nextInt(); if (chislo3 > 110) { System.out.println("ты молодец, теперь введи свое имя, имей ввиду если ты Андрей то у тебя проблемы"); userAnswer = scn.nextLine(); if(!userAnswer.equals("Андрей")) { System.out.println("Приятно познакомиться " + userAnswer + ", а меня зовут Жора"); } } } } }else if(userAnswer.equals("n")){ System.out.println("ой ебать иди нахуй"); } else{ System.out.println("у тебя два варианта даунич"); } }while(userAnswer.equals("Андрей")); } - I also did when you wrote to me that I refer to a variable that has not yet been declared. Now the userNumber inside the loop is highlighted in red and the idea says that "is already defined in the scope" - jewbaka
- @jewbaka carefully compare your code with the code in the answer. - Sergey Gornostaev
- @SergeyGornostaev it's hard to call it code - raviga pm
- one@raviga agree. I did him a disservice - Miron
The code did not run, but I can definitely say one thing. You can answer no. That is bad luck - the lines stroka2, stroka3, stroka4 do not exist in nature, since you create them only with an affirmative answer. You refer to the fields that are not in memory. I advise you to declare them before the do-while loop, or at the very beginning before the start of the "logic".
And yes - you could use only one variable (from those where there could be "Andrei"). Look carefully at the branch. You enter only one variable anyway. Why do you need three?
- Error: (17, 28) java: variable stroka2 already defined in main (java.lang.String []) Error: (28, 32) java: variable stroka3 defined in main (java.lang.String [ ]) Error: (38, 36) java: variable stroka4 is already defined in java.lang.String [] - jewbaka
- Can you update the code (in question)? - Miron