0

Please where is the default

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=firstBadGuy){ System.out.println("BadGuy"); } } }

27th Nov 2021, 6:08 PM
Achraf Soua
4 odpowiedzi
+ 3
Achraf Soua Please read this lesson about for loop: https://www.sololearn.com/learning/2147/ If your loop should run from 1 to 7: for(int i = 1; i <= 7; i++){ } First part initialize: int i = 1 Second part end condition: i <= 7 Third part increment/decrement: i++ (add 1 to i) But you should also mention the challenge you want to solve. I don't think that you need to print "BadGuy" 7 times. ;)
27th Nov 2021, 7:57 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
I think you need to learn again how for loop works. . if your input to firstBadGuy is <=7 then it's a infinite loop.. otherwise it prints BadGuy once only... your question is not clear.. what actually your task there? what's your expected output. ?
27th Nov 2021, 6:14 PM
Jayakrishna 🇮🇳
27th Nov 2021, 6:35 PM
Simon Sauter
Simon Sauter - avatar
0
for(int i=1;i<=7;i=firstBadGuy) This line is giving you an error. Please send the question
27th Nov 2021, 6:24 PM
Adi Nath Bhawani
Adi Nath Bhawani - avatar