Hi,
Here is the modified program, it compiles and execute
fine! the part you need to implement is when the user
enter the largest temperature first.
Good Luck
Manuel

/**
  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      tempC, tempF, temp2;
              double  temp1, degreesC, degreesF;
              String  degrees,startTemp, endTemp;
             
              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.equalsIgnoreCase("c")) {
                     degreesF = temp1;
                     degreesC = 5 * (degreesF - 32)
/9;
                    
JOptionPane.showMessageDialog(null, degreesF + "
Fahrenheit = " + degreesC + " Celsius");
                  }
                  else if (
degrees.equalsIgnoreCase("f"))  {
                      degreesC = temp1;
                      degreesF = ( 9 * (degreesC) / 5
) + 32;
                      JOptionPane.showMessageDialog
(null, degreesC + " Celsius = " + degreesF + "
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");
              
                 //Convert numbers from type String to
type int
                 temp2 = Integer.parseInt(startTemp);
                 tempC = Integer.parseInt(endTemp);

                 JTextArea outputTextArea = new
JTextArea();
             
                 if ( (temp2 <= tempC) &&
(degrees.equalsIgnoreCase("c"))) {
                    //loop to print the range temp
                    for (int i=temp2; i <= tempC; i++)
{
                        temp2 = 5 * ( temp2 - 32 ) /
9;
                        outputTextArea.append(i + " F
= " + temp2 + " C \n");
                        //temp2++;           
                    }
                   
JOptionPane.showMessageDialog(null,outputTextArea,"List
of 

Temperatures",JOptionPane.INFORMATION_MESSAGE);
                    System.exit(0);   // exit system
                 }
   
                 else if ( (temp2 <= tempC) &&
(degrees.equalsIgnoreCase("f"))) {
                    //loop to print the range temp
                    for (int i=temp2; i <= tempC; i++)
{
                        temp2 = ( 9 * (temp2) / 5) +
32;
                        outputTextArea.append(i + " C
= " + temp2 + " F \n");
                       //temp2++;
                    }
                   
JOptionPane.showMessageDialog(null,outputTextArea,"List
of 

Temperatures",JOptionPane.INFORMATION_MESSAGE);
                    System.exit(0);   // exit system
                }
                if (temp2 > tempC) {
                   temp2 = temp2 - tempC;
                   startTemp =
JOptionPane.showInputDialog("Your starting temperature
is: " +temp2 + " above your ending 

temperature. \n" + "Please choose another number lower
than: " + endTemp);


                   System.exit(0);
              
                }      
                else
              {
                    degrees =
JOptionPane.showInputDialog("Please enter either C to
convert to Celsius or F to convert to 

Fahrenheit.");
              }    
                   
        }
  }

--- njdude20 <[EMAIL PROTECTED]> 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.");
>               }
>                       
>       }
> }
> 
> 
> 
> 



                
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 



------------------------ 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=5469
    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