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"); } } }
4 Antworten
+ 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. ;)
+ 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. ?
+ 1
Take a look at these guides on how to ask a question.
https://stackoverflow.com/help/how-to-ask
https://www.sololearn.com/blog/38/8-simple-rules-to-get-help-from-the-community
Please always tag the language you're asking about.
https://code.sololearn.com/W3uiji9X28C1/?ref=app
0
for(int i=1;i<=7;i=firstBadGuy)
This line is giving you an error.
Please send the question