0

My if statement (the one holding all the others) is running as false and I don't understand what I'm doing wrong. Here's a portion of my code. I really appreciate any help I can get as this is a school assignment

 import java.util.Scanner;

public class StatesOfWater
{
   public static void main( String[]args )
   {
     Scanner water = new Scanner(System.in);

     System.out.println("Enter a unit ( C for Celcius and F for Fahrenheit): ");
     String unit = water.next();

     System.out.println("Enter a temperature: ");
     int temp = water.nextInt();
     String c = "C";
     String f = "F";


     if (unit == c) //not assigning, equaliziing
     {
         if ( temp <= 0)
         {
             System.out.println("The state is solid.");
         }

         else if ( temp > 0 && temp < 100.00)
         {
             System.out.println("The state is liquid.");
         }

         else if (temp >= 100.0)
         {
             System.out.println("This is a gas");
         }
         else
         {
             System.out.println("error2?");
            }
    }
    else 
    {
        System.out.println("error?");
    }
}
}

Using () instead of == does not compile as im using Java 7.

0 Answers0