Search This Blog

Friday, January 21, 2011

Temperature Converter

In this tutorial, we'll make a Temperature converter that converts the temperature from Fahrenheit to Celsius. Once you go through this tutorial, try to make a converter that goes from Celsius to Fahrenheit. Leave a video of it in the comments, or just the source code.
Here is the tutorial:
Source code:

import TerminalIO.KeyboardReader;

public class Convert{
    public static void main(String[] args){
        KeyboardReader reader = new KeyboardReader();
        double fahrenheit;
        double celsius;
      
        fahrenheit = reader.readDouble("Enter the temperature in Farenheit: ");
      
        celsius = (fahrenheit - 32.0) * 5.0 / 9.0;
      
        System.out.println("The equivalent in Celsius is: " + celsius);
  
    }
 
}

No comments:

Post a Comment