• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

Have you ever wanted to convert Fahrenheit to Celsius in java? Now you can!

October 24, 2012 by Rick Hernandez Leave a Comment


package temperature.conversions;

import java.util.Scanner; 


public class TemperatureConversions 
{
    public static void main(String[] args) 
    {
        double Selection;
        
        Scanner input = new Scanner(System.in);
        
        // create a menu to select item from
        System.out.println("Welcome, to temperature conversion program select one of the options: ");
        System.out.println("1.Convert to Celsius");
        System.out.println("2.Convert to fahrenheit");

        Selection = input.nextDouble();

        if (Selection == 1)
        {
            System.out.println("Eneter temperature amount: ");
            Selection = input.nextDouble();
            
            double fahrenheit = celcious(Selection);
            
            System.out.println("Celsius is: " + fahrenheit);
        } // end of if statement
        
        else 
        {
            Selection = input.nextDouble();
            System.out.println("Eneter temperature amount: ");
            double celcious = fahrenheit(Selection);
            
            System.out.println("celcious is: " + celcious);
            
        } // end of else statement
        
        
    } // end of main 
    
    /****** Method 1 Celcius *******/
    public static double celcious(double Fahrenheit)
    {
        double Celcious = 9.0 /5.0 * Fahrenheit + 32.0;
       
        return Celcious;
    } // end of celcious method
    
    
    /****** Method 2 Fahrenheit *******/
    public static double fahrenheit(double Celsius)
    {
        double Fahrenheit =  5.0 / 9.0 * (Celsius - 32.0);
        
        return Fahrenheit;     
    } // emd of fahrenheit double
    
}// end of TemperatureConversions class


Rick Hernandez

I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: Java, Programming

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in