Answer to Question #324722 in Java | JSP | JSF for Holly

Question #324722

A Shorter Three (JAVA)

by CodeChum Admin

Numbers in threes are awesome! But the one last time was too lengthy to look at, so I just want to view it in a shorter but still readable format.


You okay with this task?


Instructions:

  1. Print out all numbers from 1 to 100 that is divisible by 3 using a for loop just like the last problem, but this time, with each number only separated by the space like that of the sample output.

Output

A line containing integers divisible by 3 separated by a space.

3·6·9·12·15·18·21·24...
1
Expert's answer
2022-04-09T17:55:49-0400
public class Program {
    public static void main(String[] args) {
        for(int i=0; i<100;i++) {
            if(i%3==0){
                System.out.print(i+" ");
            }
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS