I'm getting my loop to print the integers 1-7 in vertical order. So like
1
2
3
4
5
6
7
That part works fine. Now I also need it to print next to it if the integer is divisible by 3. My code is as follows
for (int n = 1; n < 8; n++){
System.out.println(n );
if (n % 3 == 0){
System.out.print("divides evenly into 3");
}
}
Now my output looks like
1
2
3
divides evenly into 34
5
6
divides evenly into 37
I need the divides evenly part to be on the same line as 3 and 6. Not the line after. Anyone have any insight as to what I'm writing wrong here in my code? I am using Java.
printlnis a print line so look at that for a start.