+ 1

17.2 Java

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 sHow answer

23rd Apr 2021, 8:07 AM
Igaman Igaman
Igaman Igaman - avatar
11 Respostas
+ 4
Atul Igaman Igaman 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++) { if(c==firstBadGuy || c==secondBadGuy) System.out.println("Bad Guy"); else System.out.println("Good Guy"); } } }
23rd Apr 2021, 8:57 AM
RKK
RKK - avatar
+ 2
The code will print "Good Guy" (without quotation) 7 times in New line. Just copy and paste this code into the Java code playground and run!
23rd Apr 2021, 8:12 AM
RKK
RKK - avatar
+ 2
RKK yes I think you have implemented the correct ones
23rd Apr 2021, 10:00 AM
Atul [Inactive]
+ 1
RKK is there any logic you are getting for good and bad guy
23rd Apr 2021, 8:52 AM
Atul [Inactive]
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 = 1; x <=7; x++) { if (firstBadGuy <=1){ System.out.println("Bad guy"); if (secondBadGuy <=1) System.out.println("Bad guy"); else System.out.println("Good guy"); } } } }
23rd Apr 2021, 8:14 AM
Igaman Igaman
Igaman Igaman - avatar
0
Tell me how get right answer?
23rd Apr 2021, 8:15 AM
Igaman Igaman
Igaman Igaman - avatar
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".
23rd Apr 2021, 8:18 AM
Igaman Igaman
Igaman Igaman - avatar
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 = 1; x <=7; x++) { if (firstBadGuy <=1){ System.out.println("Bad guy"); if (secondBadGuy <=1) System.out.println("Bad guy"); else System.out.println("Good guy"); } } } }
23rd Apr 2021, 8:20 AM
Igaman Igaman
Igaman Igaman - avatar
0
Thank you, I didn't succeed, I don't have enough brains to figure out how to substitute the method variables đŸ€Ș
23rd Apr 2021, 8:26 AM
Igaman Igaman
Igaman Igaman - avatar
0
who can explain the cycles?
23rd Apr 2021, 9:02 AM
Igaman Igaman
Igaman Igaman - avatar
0
Good Guy will be printed on each line 7 times
25th Apr 2021, 12:40 AM
MacJr
MacJr - avatar