Knowee
Questions
Features
Study Tools

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.

Question

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.

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

Solution

Sure, here is a Python implementation of the Temperature class with the two methods you requested:

class Temperature:
    def convertFahrenheit(self, celsius):
        fahrenheit = (celsius * 9/5) + 32
        return fahrenheit

    def convertCelsius(self, fahrenheit):
        celsius = (fahrenheit - 32) * 5/9
        return celsius

You can use this class like this:

temp = Temperature()
print(temp.convertFahrenheit(0))  # Output: 32.0
print(temp.convertCelsius(32))  # Output: 0.0

In this code, the convertFahrenheit method takes a temperature in Celsius and returns it in Fahrenheit. The convertCelsius method does the opposite: it takes a temperature in Fahrenheit and returns it in Celsius.

This problem has been solved

Similar Questions

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)

Fahrenheit to Celsius degreeWrite a Java program to convert temperature from Fahrenheit to Celsius degree.The Fahrenheit scale is a temperature scale based on one proposed in 1724 by physicist Daniel Gabriel Fahrenheit. It uses the degree Fahrenheit (symbol: °F) as the unit.The Celsius scale, previously known as the centigrade scale, is a temperature scale used by the International System of Units (SI). As an SI derived unit, it is used by all countries in the world, except the U.S.Note:One inch is 0.0254 meter.Print upto 1 value after decimal Sample Input:Input a degree in FahrenheitSample Output:Output will have the Celsius degree value of the Fahrenheit degree input valueClick on the image for preview.Constraints:NAExample:Input:212Output:100.00Explanation:-Click on the image for preview.Public Test Cases:# INPUT EXPECTED OUTPUT1 212100.02 300148.9

Which is the correct formula for converting degrees Celsius to degree Fahrenheit

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

1/3

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.