How does this below work? I know about the ?: comparison operator, I mean
how did you get it to print the original name? See below:

longestname=(lengthofname1>lengthofname2)?name1:name2;
longestname=(longestname>lengthofname3)?longestname:name3;

System.out.println(longestname + " has the longest first name!");

Hope I helped.

Regards,
Manu.


I too was going to try this, but doing it this way is even longer. You are
going to end up with longestname = name1 2 or 3
How do you know which one it is assigned too? Wouldn't you have to loop
through them to compare them to a boolean and print the statement if so?
I would really like to see the code you used for the Homework, because I
used the one that Rene used.
I am sure that you have name1 and so on assigned to the split name indexed
at zero, then you probably have another variable assigned to the array which
has the full name before the split.

Thanks,
Stephen


On Fri, Sep 19, 2008 at 1:40 PM, Manu? <[EMAIL PROTECTED]> wrote:

> String longestname;
>
> longestname=(lengthofname1>lengthofname2)?name1:name2;
> longestname=(longestname>lengthofname3)?longestname:name3;
>
> System.out.println(longestname + " has the longest first name!");
>
> Hope I helped.
>
> Regards,
> Manu.
>
>
> On Fri, Sep 19, 2008 at 3:14 PM, Rene Erwee <[EMAIL PROTECTED]> wrote:
>
>>  Hi all
>>
>>
>>
>> Thank you David for your good explanation of String Arrays which finally
>> enabled me to finish the homework.  However, I am wondering if there is a
>> more condensed version to find and print the longest name.  I can imagine
>> If-else-else if statements will not work too well when one has a whole lot
>> of names to compare.
>>
>>
>>
>>         // Print the longest name
>>
>>             if((lengthOfFirstNameOfPerson1>=lengthOfFirstNameOfPerson2) &&
>>
>>         (lengthOfFirstNameOfPerson1>=lengthOfFirstNameOfPerson3)){
>>
>>             System.out.println(firstNameOfPerson1[0] + " has the longest
>> first name");
>>
>>         }
>>
>>         else if ((lengthOfFirstNameOfPerson2>=lengthOfFirstNameOfPerson1)
>> &&
>>
>>         (lengthOfFirstNameOfPerson2>=lengthOfFirstNameOfPerson3)){
>>
>>             System.out.println(firstNameOfPerson2[0] + " has the longest
>> first name");
>>
>>         }
>>
>>         else {
>>
>>             System.out.println(firstNameOfPerson3[0] + " has the longest
>> first name");
>>
>>         }
>>
>>     }
>>
>>     }
>>
>>
>>
>> Thanks
>>
>> * *
>>
>> *Rene Erwee*
>>
>>
>>
>
>
> --
> This email may contain confidential and privileged proprietary material for
> the sole use of the intended recipient. Any review, use, or distribution or
> disclosure by others is strictly prohibited. If you are not the intended
> recipient, or authorized to receive the information from the recipient,
> please contact the sender by reply email and delete all copies of this
> message.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to