I only need help with 1 of the programs now. It says to list all the postive integers less than 400 that are divisible by 3

Recommended Answers

All 5 Replies

So, what's your question?

What I'm saying is that I have no clue how to do it. The problem on the test said "list all of the positive integers less than 400 that are divisible by 3." I want to know what the code actually looks like due to the fact that I had no clue on the test. So my question is what is the code that lists all the positive integers less than 400 that are divisible by 3?

if ( number % 3 == 0 ) you get your number divisible by 3. Oviously you need to increment your number, you need to check that is smaller then 400 and then capture it somewhere

Simple like that

thanks, I didn't know it was that simple

for(num = 1; num<= 400; num ++)
{
if ((num % 3) == 0);
{
.......showMessageDialog(num);
}
}

or something like that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.