Else/if Statement


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Else/if Statement

  1. #1
    Join Date
    Feb 2006
    Posts
    8

    Unhappy Else/if Statement

    if/else
    Last edited by leospyder; 02-05-2009 at 01:16 AM.

  2. #2
    Join Date
    Feb 2006
    Posts
    4
    Hi

    Change this line "else if (18<=age<=64)"

    to this else if (age>=18 && age<=64)

    you need && (AND) to and any two conditions, also || to OR

    Hope this helps

  3. #3
    Join Date
    Dec 2005
    Location
    New Jersey
    Posts
    290
    Quote Originally Posted by leospyder
    if (age<18)
    minors= minors+1;
    else if (18<=age<=64)
    adults=adults+1;
    else
    seniors=seniors+1;
    The "else if (18<=age<=64)" statement is not legal. You need to do something like else if (age >= 18 && age <= 64).

    You could also do:
    Code:
    
    if (age > 64) {
        seniors++;
    } else if (age > 18) {
        adults++;
    } else {
        minors++;
    }
    Last edited by destin; 02-27-2006 at 07:42 AM.

  4. #4
    Join Date
    Feb 2006
    Posts
    8
    thanks dev_j it worked

Similar Threads

  1. Replies: 2
    Last Post: 05-18-2003, 11:16 PM
  2. Returning a sql statement...
    By Chiodo in forum Database
    Replies: 0
    Last Post: 05-21-2002, 11:23 AM
  3. Replies: 0
    Last Post: 05-07-2002, 09:34 PM
  4. Access And SQL date statement
    By Saiful in forum VB Classic
    Replies: 7
    Last Post: 11-24-2000, 06:21 AM
  5. Select statement in ASP
    By Victor Tai in forum Web
    Replies: 1
    Last Post: 07-24-2000, 12:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center