Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Temperature class that will hold a temperature in Fahrenheit, and provide meth- ods to get the temperature in Fahrenheit, Celsius, and Kelvin. The

Write a Temperature class that will hold a temperature in Fahrenheit, and provide meth- ods to get the temperature in Fahrenheit, Celsius, and Kelvin. The class should have the following field: ftemp A double that holds a Fahrenheit temperature. The class should have the following methods: Constructor The constructor accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field. setFahrenheit The setFahrenheit method accepts a Fahrenheit temperature (as a double) and stores it in the ftemp field. getFahrenheit Returns the value of the ftemp field, as a Fahrenheit temperature (no conversion required). getCelsius Returns the value of the ftemp field converted to Celsius. getKelvin Returns the value of the ftemp field converted to Kelvin. Use the following formula to convert the Fahrenheit temperature to Celsius: Celsius = (5/9) * (Fahrenheit - 32) Use the following formula to convert the Fahrenheit temperature to Kelvin: Kelvin = ((5/9) * (Fahrenheit - 32)) + 273 Demonstrate the Temperature class by writing a separate program called TemperatureDemo that asks the user for a Fahrenheit temperature. The program should create an instance of the Temperature class, with the value entered by the user passed to the constructor. The program should then call the objects methods to display the temperature in Celsius and Kelvin.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions