New course! Every coder should learn Generative AI!
0

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(); for(int c=1; c<=7; c++) { System.out.println("Good Guy"); } } } Thatโs all๐ please do not write an answer, try to explain how to do it

20th Apr 2021, 5:26 PM
Igaman Igaman
+ 2
When you click on the question the question is divided into 3 sections. Problem,code and result. I am asking you to copy the problem section and paste it here
20th Apr 2021, 5:46 PM
Atul [Inactive]
+ 2
@Denise Roรberg Ok, I was wondering, because in the explanation it shows them as strings, but his code shows getting ints. Anyway similar principle just loop and compare ints instead, without the use of the array.
20th Apr 2021, 6:28 PM
ChaoticDawg
+ 1
20th Apr 2021, 5:38 PM
Atul [Inactive]
+ 1
I said question the explanation provided . Don't post you code again and again
20th Apr 2021, 5:40 PM
Atul [Inactive]
+ 1
Igaman Igaman What you need inside your loop is an if/else statement. compare the value of c with the values of firstBadGuy and secondBadGuy -> equal? print "Bad Guy" else print "Good Guy".
20th Apr 2021, 6:18 PM
Denise Roรberg
+ 1
Igaman Igaman Try making a String array with the values "one", "two", "three"... etc. Then loop over the array using an enhanced for loop. In the loop check the current value of the array against the values of firstBadGuy and secondBadGuy. If firstBadGuy or secondBadGuy is equal() to the current value of the array, then output "Bad guy" else output "Good guy"
20th Apr 2021, 6:23 PM
ChaoticDawg
+ 1
ChaoticDawg The values are given as integers in this task.
20th Apr 2021, 6:25 PM
Denise Roรberg
0
20th Apr 2021, 5:35 PM
Atul [Inactive]
0
20th Apr 2021, 5:35 PM
Atul [Inactive]
0
I think use โbreakโ and โcontinueโ Yeah?
20th Apr 2021, 5:36 PM
Igaman Igaman
0
???
20th Apr 2021, 5:43 PM
Igaman Igaman
0
You are playing and now you are working on a game that deals 7 cards that indicate the roles of the players. 5 of them give the role of the good guys, and 2 - the bad. Write a bad program that will accept password numbers as input and enter all roles accordingly. Sample input one four Result example Bad guy Good guy Good guy Bad guy Good guy Good guy Good guy Explanation 1st and 4th roles - "Bad guy".
20th Apr 2021, 5:49 PM
Igaman Igaman
0
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(); for (int x = 0; x <=7; x++) { if (x >= 5) { break; } System.out.println("Good guy"); if ( x >= 2) { continue; } System.out.println("Bad guy"); } } } ๐๐๐
20th Apr 2021, 6:22 PM
Igaman Igaman
0
.........
20th Apr 2021, 7:42 PM
Igaman Igaman
0
I didn't succeed, I don't have enough brains to figure out how to substitute the method variables
21st Apr 2021, 4:16 AM
Igaman Igaman
0
Common, give me something
21st Apr 2021, 2:48 PM
Igaman Igaman
0