I was messing around with a for loop, and ended up with this.
import java.util.Scanner;
public class Inputs {
public static void main(String[] args) {
System.out.println("Enter any number 0-5.");
Scanner scan = new Scanner (System.in);
int num1 = scan.nextInt ();
for (int x = 0; x < scan.nextInt (); x++) {
System.out.println("Just right.");
}
}
}
The program runs just fine, I messed with it a few times and these were my answers.
Enter any number 0-5.
5
3
Just right.
5
Just right.
6
Just right.
I have no idea why it does that, I'm going to assume that it has something to do with the x++. Any help would be appreciated. Also, I"m very new at this, so keep your harsh comments to yourself.
Why you be a minen' in me mines? If you need to contact me, a private message is the way to go. I almost never come back to a topic after I've commented on it.
you're doing a "for" loop
the program will continue printing "just right" as long as the input number is lower than x, it will keep at it until it surpasses the input, due to x++ increasing it
you're doing a "for" loop
the program will continue printing "just right" as long as the input number is lower than x, it will keep at it until it surpasses the input, due to x++ increasing it
Great, thanks a lot!
Rollback Post to RevisionRollBack
Why you be a minen' in me mines? If you need to contact me, a private message is the way to go. I almost never come back to a topic after I've commented on it.
The program runs just fine, I messed with it a few times and these were my answers.
Enter any number 0-5.
5
3
Just right.
5
Just right.
6
Just right.
I have no idea why it does that, I'm going to assume that it has something to do with the x++. Any help would be appreciated. Also, I"m very new at this, so keep your harsh comments to yourself.
If you need to contact me, a private message is the way to go. I almost never come back to a topic after I've commented on it.
the program will continue printing "just right" as long as the input number is lower than x, it will keep at it until it surpasses the input, due to x++ increasing it
Great, thanks a lot!
If you need to contact me, a private message is the way to go. I almost never come back to a topic after I've commented on it.