Current location: Hot Scripts Forums » Programming Languages » Everything Java » Nested IF problem


Nested IF problem

Reply
  #1 (permalink)  
Old 02-17-04, 03:08 PM
java_hates_me java_hates_me is offline
New Member
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Nested IF problem

Hello ppl

I really need some help I'm new to java as it is but I'm teaching myself bit by bit and I'm writing a program that can do searches now I got it to work and everything but i want to change it into a nested IF statement and I believe that nested IF's are an IF within an IF but I cant fathom out how to convert the code I had before into a nested IF now so example of this would be appreciated.

thanks

this is the code I did to perform a search within an array, its also what I'm trying to convert to nested IF's..

//================================

for (int row=0;row<Firstname.length;row++){

if (options==1)
{
if (Cycle[row].equals("Yes"))
{
System.out.println(Firstname[row]+" "+Surname[row]+" "+Cycle[row]);

}
}
}

for (int row=0;row<Smoker.length;row++){

if (options==2)
{
if (Smoker[row].equals("Yes"))
{
System.out.println(Firstname[row]+" "+Surname[row]+" "+Smoker[row]);

}
}
}

//================================
Reply With Quote
  #2 (permalink)  
Old 02-17-04, 06:07 PM
stdunbar stdunbar is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Superior, CO, USA
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
How about something like:

if ((options==1) && (Cycle[row].equals("Yes"))
System.out.println(Firstname[row]+" "+Surname[row]+" "+Cycle[row]);

And remember, Java hates no one but it is not too fond of Microsoft people



Quote:
Originally Posted by java_hates_me
Hello ppl

I really need some help I'm new to java as it is but I'm teaching myself bit by bit and I'm writing a program that can do searches now I got it to work and everything but i want to change it into a nested IF statement and I believe that nested IF's are an IF within an IF but I cant fathom out how to convert the code I had before into a nested IF now so example of this would be appreciated.

thanks

this is the code I did to perform a search within an array, its also what I'm trying to convert to nested IF's..

//================================

for (int row=0;row<Firstname.length;row++){

if (options==1)
{
if (Cycle[row].equals("Yes"))
{
System.out.println(Firstname[row]+" "+Surname[row]+" "+Cycle[row]);

}
}
}

for (int row=0;row<Smoker.length;row++){

if (options==2)
{
if (Smoker[row].equals("Yes"))
{
System.out.println(Firstname[row]+" "+Surname[row]+" "+Smoker[row]);

}
}
}

//================================
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php in linux problem usman PHP 6 05-15-04 11:57 AM
User Authentication and Session problem!!! askme PHP 1 02-06-04 09:10 AM
nested table problem skerg HTML/XHTML/XML 2 01-25-04 06:10 PM
Small problem for a pro, but for novice like me... argh! ntek Perl 3 11-19-03 01:45 PM
jpGraph axis labeling problem Squeezer PHP 2 08-20-03 07:53 AM


All times are GMT -5. The time now is 05:59 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.