What is the mistake | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

What is the mistake

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int firstBadGuy = read.nextInt(); int secondBadGuy = read.nextInt(); //your code goes here ; for(int i = 1; i <= 7; i++) { if(i == firstBadGuy && i == secondBadGuy ) { System.out.println("Bad guy"); } else { System.out.println("Good guy"); } } } }

27th Nov 2021, 8:29 PM
Achraf Soua
4 Answers
+ 3
Is it the same task as here? https://www.sololearn.com/Discuss/2930896/?ref=app If so, you don't need to create a new thread – just post in the old thread :) Also, people can help you much quicker, if you describe the task, tag the relevant programming language and put your code in a script!
27th Nov 2021, 9:05 PM
Lisa
Lisa - avatar
+ 2
Idk what the code should do. But with "&&" this code will only print "Bad guy" if both guys have the same number. Maybe you want to print that for each bad guy. Then you have to use an "||" or.
27th Nov 2021, 8:49 PM
Coding Cat
Coding Cat - avatar
+ 2
Please tag the language name relevant to your code and question (Java), rather than 'help' ☝ What was the task requirement?
27th Nov 2021, 8:50 PM
Ipang
+ 2
Achraf Soua What is the name of the challenge.? Can you give example inputs and output with a brief description of requirements
27th Nov 2021, 11:04 PM
Rik Wittkopp
Rik Wittkopp - avatar