17.2 Java | Sololearn: Learn to code for FREE!

+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

4/23/2021 8:07:04 AM

Igaman Igaman

14 Answers

New Answer

+5

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"); } } }

+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!

+2

RKK yes I think you have implemented the correct ones

+1

RKK is there any logic you are getting for good and bad guy

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"); } } } }

0

Tell me how get right answer?

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".

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"); } } } }

0

Thank you, I didn't succeed, I don't have enough brains to figure out how to substitute the method variables 🤪

0

who can explain the cycles?

0

Good Guy will be printed on each line 7 times