Thanks to all respondants!  I understand what I did wrong and it's
working now.  :)

On Jul 23, 4:57 am, Kaka madiba <[email protected]> wrote:
> Hi,
>  
> You should change  char min = ""; to String min =" "; Try the below code:
>             //declares the numbers
>       int num1 = 10;
>       int num2 = 23;
>       int num3 = 5;
>       int zero = 0; // variable to store smallest number
>      
>          //determines the smallest number
>        zero = (num1 < num2) ? num1 : num2; // zero will get value of smallest 
> number between num1 & num2
>        zero = (zero < num3) ? zero : num3; // zero will get value of smallest 
> number between zero & num3
>
>  
>        //get string to print out
>         String min = "";
>  
> //check if smallest number is less than 10 or >= and get string to print out
>         min = (zero < 10) ? "The smallest number is less than 10!" : "The 
> smallest number is greater than or equal to 10!" ;
>         System.out.println(min);
>  
>  
>
> --- On Thu, 7/23/09, * ^ * <[email protected]> wrote:
>
> From: * ^ * <[email protected]>
> Subject: [java programming] Re: LAB 1002 - Incompatible types error
> To: "Free Java Programming Online Training Course By Sang Shin" 
> <[email protected]>
> Date: Thursday, July 23, 2009, 1:54 AM
>
> On Jul 23, 8:00 am, "tinyang" <[email protected]> wrote:
>
> > Hi all.
>
> > Here is my code for MyGreatestValueProject2.  I'm getting a "Incompatible
> > types" compile error on the following line:
> > min = (zero < num3) ? "The smallest number is less than 10!" : "The smallest
> > number is greater than or equal to 10!";
>
> > I think I understand the problem which is declaring min as a char variable
> > type, then saying it equals an equasion with intergers in it, but I'm not
> > sure how to fix it.  Can someone give me a hint or explain to me how this
> > should be done and why?  Thanks!
>
> > ----------------------Code---------------------------------
>
> > public class GreatestValue2 {
>
> >     /**
> >      * @param args the command line arguments
> >      */
> >     public static void main(String[] args) {
> >         // TODO code application logic here
>
> >         //declares the numbers
> >         int num1 = 10;
> >         int num2 = 23;
> >         int num3 = 5;
> >         int max = 0;
> >         int zero = 0;
> >         char min = "";
>
> >         //determines the highest number
> >         max = (num1 > num2) ? num1 : num2;
> >         max = (max > num3) ? max : num3;
>
> >         zero = (num1 < num2) ? num1 : num2;
> >         min = (zero < num3) ? "The smallest number is less than 10!" : "The
> > smallest number is greater than or equal to 10!";
>
> Besides the fact Babu has pointed out. A possible solution:
> int min=zero < num3 ? zero : num3;
> String minvalue=min < 10 ? "The smallest number is less than 10!" :
> "The smallest number is greater than or equal to 10!";
>
>
>
> >         //prints the output on the screen
> >         System.out.println("number 1 = " + num1);
> >         System.out.println("number 2 = " + num2);
> >         System.out.println("number 3 = " + num3);
> >         System.out.println("The highest number is = " + max);
> >         System.out.println(min);
> >     }
>
> > }
>
> > --
> > :-)
> > P Please don't print this e-mail unless you really need to.
>
> >  <http://www.crossloop.com/Teenah>
>
>

--~--~---------~--~----~------------~-------~--~----~
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