The line degrees = JOptionPane.showInputDialog("Enter C to convert 
Celsius or F Fahrenheit.");
is wrong. JOptionPane.showInputDialog returns a String, not a char. 
Change the type of degrees to String.

If there are any other errors, please say on which line, that makes it 
easier for other people to see wat's wrong.

-- 
  Mark Van Peteghem
  http://www.q-mentum.com -- easier and more powerful unit testing


njdude20 wrote:

>
> I am very new to Java programming and I am taking courses online
> through the University of Maryland. I need help figuring out how to
> fix the problem in one of the programs I am writing. I am entering
> the program in JCreator and when I go to compile the program I get
> an error message of incompatiable types. How do I fix this? Here is
> the file:
> /**
> This program is written to convert temperatures from
> and also Celsius to Fahrenheit or from Fahrenheit to Celsius and
> to print a range of temperatures that you want.
> */
> import javax.swing.*;
>
> public class TempConv
> {
>       public static void main(String[] args)
>       {
>             String  temp;
>             int     startTemp, endTemp, tempC, tempF, temp2;
>             double  temp1, degreesC, degreesF;
>             char    degrees;
>            
>             temp = JOptionPane.showInputDialog(
>                   "Enter any temperature (either Celsius or
> Farhenheit that you would like to convert");
>             temp1 = Double.parseDouble(temp);
>            
>             degrees = JOptionPane.showInputDialog(
>                   "Enter C to convert Celsius or F 
> Fahrenheit.");
>                  
>                 if ( (degrees == 'c') || (degrees == 'C') )
>                 {
>                         degreesF = temp1;
>                         degreesC = 5 * (degreesF - 32) /9;
>                         JOptionPane.showMessageDialog(null,
>                               degreesF + " Fahrenheit = "
> + degreesC + " Celsius");
>                   }
>                         else if ( (degrees == 'f') ||
> (degrees == 'F') )
>                         {           
>                               degreesC = temp1;
>                               degreesF = ( 9 *
> (degreesC) / 5 ) + 32;
>                               JOptionPane.showMessageDialog
> (null,
>                                     degreesC + " Celsius
> = " + degreesF + " Fahrenheit.");
>                         }
>                              
>                               else
>                               {
>                               degrees =
> JOptionPane.showInputDialog(
>                                     "Enter either C to
> convert to Celsius or F to convert to Fahrenheit");
>                               }
>            
>             startTemp = JOptionPane.showInputDialog(
>                   "Enter a whole number starting
> tempterature.");
>                  
>             endTemp = JOptionPane.showInputDialog(
>                   "Enter a whole number ending temperature
> higher than the starting temperature.");
>            
>             degrees = JOptionPane.showInputDialog(
>                   "To convert to Celsius enter C and to
> convert to Fahrenheit enter F");
>             temp2 = startTemp;
>                  
>             if ( ( (temp2 <= endTemp) && ( (degrees == 'c') ||
> (degrees == 'C') ) ) )
>             {
>                   tempC = 5 * ( temp2 - 32 ) / 9;
>                   JOptionPane.showMessageDialog(null,
>                         temp2 + " F = " + tempC + " C \n");
>                   temp2++;           
>             }
>             else if ( ( (temp2 <= endTemp) && ( (degrees == 'f')
> || (degrees == 'F') ) ) )
>             {
>                   tempF = ( 9 * (temp2) / 5) + 32;
>                   JOptionPane.showMessageDialog(null,
>                         temp2 + " C = " + tempF + " F \n");
>                   temp2++;
>             }
>             else if (temp2 > endTemp)
>             {
>                   temp2 = temp2 - endTemp;
>                   startTemp = JOptionPane.showInputDialog(
>                         "Your starting temperature is: " +
> temp2 + "above your ending temperature. \n" +
>                         "Please choose another number lower
> than: " + endTemp);
>             }
>             else
>             {
>                   degrees = JOptionPane.showInputDialog(
>                   "Please enter either C to convert to Celsius
> or F to convert to Fahrenheit.");
>             }
>                  
>       }
> }



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/beginnersclub/post?act=reply&messageNum=5466
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/beginnersclub/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to