Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

Explain the temperature converter Java?

Asked by Keith Sutherland Oct 11, 2022 1.5K views 1 answer
Share

About this question

 I have made a program that converts Celsius to Fahrenheit and Fahrenheit to Celsius. How is my code?


import java.util.Scanner;
public class TemperatureConversion {
    public static void main(String[] args) {
        double fahrenheit, celsius;
        Scanner input = new Scanner(System.in);
        //  Celsius to Fahrenheit u2103 degree Celsius symbol
        System.out.println("Input temperature (u2103): ");
        celsius = input.nextDouble();
        System.out.println(celsius * 1.8 + 32 + " u2109 n");
        // Fahrenheit to Celsius u2109 degree Fahrenheit symbol
        System.out.println("Input temperature (u2109: ");
        fahrenheit = input.nextDouble();
        System.out.print((fahrenheit - 32) / 1.8 + " u2103");
    }

Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.