title: calculating the matter state of water using if statements?
body: <p>I need to calculate the state of water solid, liquid or gas by taking user input of the temperature in either Celsius or Farenheit and the altitude in either feet or Meters.</p>
  
  <p>When I try and run the program it always says the water is gaseous. I can't seem to figure out what I am missing. or doing wrong.</p>
  
  <pre><code>public class Water 
  {
  
     private final double temperature;
     private final String degrees;
     private final int altitude;
     private final String units;
     private final double bpFeet;
     private final double bpMeters;
     private String waterState;
  
  
     public Water(double temp, String deg, int alt, String unitType)
     {
         temperature = temp;
         degrees = deg;
         altitude = alt;
         units = unitType;
         bpFeet = temperature - (altitude * 0.001); //boiling point given an altitude in feet
         bpMeters = temperature - (altitude * 0.01); //boiling point given an altitude in meters
     }
  
     public String getState()
     {
  
          if (degrees.equals("F"))
          {
                     if (units.equals("Ft"))
                     {
                         if (temperature &gt;= bpFeet)
                         {
                             waterState = "The water is gaseous.";
                             System.out.println(waterState);
                         }
                         else if (temperature &gt; 32 &amp;&amp; temperature &lt; bpFeet)
                         {
                             waterState = "The water is liquid.";
                             System.out.println(waterState);
                         }
                         else
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                     }
  
                     else if (units.equals("M"))
                     {
                         if (temperature &lt;= bpMeters)
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                         else if (temperature &gt; 32 &amp;&amp; temperature &lt; bpMeters)
                         {
                             waterState = "The water is liquid.";
                             System.out.println(waterState);
                         }
                         else 
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                     }
                     else
                     {
                         System.out.println("Error: must enter FT (feet) or M (meters)");
                     }
          }
  
          else if (degrees.equals("C"))
          {
                     if (units.equals("Ft"))
                     {
                         if (temperature &gt;= bpFeet)
                         {
                             waterState = "The water is gaseous.";
                             System.out.println(waterState);
                         }
                         else if (temperature &gt; 0 &amp;&amp; temperature &lt; bpFeet)
                         {
                             waterState = "The water is liquid.";
                             System.out.println(waterState);
                         }
                         else
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                     }
  
                     else if (units.equals("M"))
                     {
                         if (temperature &lt;= bpMeters)
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                         else if (temperature &gt; 0 &amp;&amp; temperature &lt; bpMeters)
                         {
                             waterState = "The water is liquid.";
                             System.out.println(waterState);
                         }
                         else 
                         {
                             waterState = "The water is solid.";
                             System.out.println(waterState);
                         }
                     }
                     else
                     {
                         System.out.println("Error: must enter FT (feet) or M (meters)");
                     }
         }
  
         else
         {
             System.out.println("Error: must enter C (centigrade) or F (farenheit)");
         }
  
  
  
             return temperature + degrees + " " + altitude + units;
  
  
     }
  
  
  }
  </code></pre>
  
  <p>Here is the class with the main method I was using just to test this class.</p>
  
  <pre><code>public class WaterState 
  {
      public static void main(String[] args)
      {
      Water timWater = new Water(-100, "C", 1000, "Ft");
  
  
      String newWater = timWater.getState();
      System.out.println(newWater);
  
      }
  }
  </code></pre>