Knowee
Questions
Features
Study Tools

WAP in Java to input temperature in Fahrenheit and convert it in Celsius.         C= (F-32)*5/9

Question

WAP in Java to input temperature in Fahrenheit and convert it in Celsius.         C= (F-32)*5/9

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Java program that takes temperature in Fahrenheit as input and converts it to Celsius:

import java.util.Scanner;

public class TemperatureConversion {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter temperature in Fahrenheit: ");
        double fahrenheit = input.nextDouble();
        double celsius = (fahrenheit - 32) * 5 / 9;
        System.out.println("Temperature in Celsius: " + celsius);
    }
}

Here's how it works:

  1. We import the Scanner class from the java.util package. This class is used to get user input.

  2. We declare a class named TemperatureConversion.

  3. Inside the TemperatureConversion class, we declare the main method. This is the entry point for any Java program.

  4. Inside the main method, we create an instance of the Scanner class named input.

  5. We prompt the user to enter a temperature in Fahrenheit.

  6. We use the nextDouble method of the input object to get the user's input as a double. We store this value in the fahrenheit variable.

  7. We convert the temperature to Celsius

This problem has been solved

Similar Questions

Create a Temprature class. Make two methods :1. convertFahrenheit - It will take celsius and will print it into Fahrenheit.2. convertCelsius - It will take Fahrenheit and will convert it into Celsius.

Write code that allow the user to enter the temperature in degrees Celsius. The program should convert it and print it in Fahrenheit degrees using the following formula: Fahrenheit =  (Celsius * 9/5) + 32 For example, if the user enters 0, then the program will print "Temperature in Fahrenheit: 32.0"

Given the temperature of the day as Celsius as input. Do convert Celsius into Fahrenheit using the formulae: Fahrenheit = ((celcius*9) /5)+32Input Format:Accept a floating point(double) value for Celsius.Output Format:Print the Fahrenheit value with respect to two decimal places(Example: 23.52F)Constraints:1<=N<=10^15Sample Input 1:32.4Sample Output 1:90.32FSample Input 2:20.0

Develop a Java program that creates a simple GUI application for atemperature converter. The program should allow users to converttemperatures between Celsius and Fahrenheit.

Convert 49 degrees F to degrees Celsius. If necessary, round your answer to the nearest tenth of a degree. Here are the formulas. C=5/9 (F-32 F=9/5 C+32

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.