Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating- point number for the temperature and

Java program image text in transcribed
Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit. Use a floating- point number for the temperature and a character for the scale, either?for Celsius or 'F' for fahrenheit. The class should have Four constructors: one for the number of degrees, one for the scale, one for both the degrees and scale, and a default constructor. For each of these constructors, assume zero degrees if no value is specified and celsius if no scale is given Two accessor methods: one to return the temperature in degrees Celsius, the other to return it in degrees Fahrenheit. Use the formulas from programming project 5 of chapter 3 and round to the nearest tenth of a degree o Degrees_C5(Degrees_F- 32)/9 o DegreesF (9(Degrees_C)5) 32) Three set methods: one to set the number of degrees, one to set the scale and one to set both Three comparison methods: one to test whether two temperatures are equal, one to test whether one temperature is greater than the other, and one to test whether one temperature is less than the other Additionally write a driver a program that tests all the methods. Be sure to invoke each of the constructors, to include at least one true and one false case for each comparison method, and to test at least the following three temperature pairs for equality. 0.0 degrees C and 32.0 degrees F, -40.0 degrees C and -40.0 degrees F, and 100.0 degrees C and 212.0 Degrees F. Make sure in the Class file to appropriately comment your code with javadoc comments for every method. (Pre and post condition comments)

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions