I want to make and If statement which will work when a double "credits" is between 1 and 9. But I'm not sure how to. Will

If (1 <= credits => 9) Then

Work?

Recommended Answers

All 3 Replies

have you tried it?
anyway, If, with capital I and Then are not from Java, so no.
for a double condition, try either nested ifs:

if ( condition1 ){
  if ( condition2 ){
    // your code
  }
}

or, put the conditions in one statement:

if ( condition1 && condition2 ){
  // your code
}

for more basic information on the if statement:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html

Thank you for your reply.
The second option you mentioned I prefer better, so if I state:

double credits;
if (credits >= 1) && (credits < 9) {
//my code

It will work, right?

You're missing a set of brackets round the whole condiiton, but otherwize that's good.
ps It's usually quicker to try something simple like that yourself than to wait for someone to reply to you.

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.