Question: Program runs in blue java and is java programming Part 3 (A More Sophisticated Object) Write a class called Temperature that has two instance variables:

Program runs in blue java and is java programmingProgram runs in blue java and is java programming Part 3 (A

Part 3 (A More Sophisticated Object) Write a class called Temperature that has two instance variables: a temp value (a floating-point number data type double) and a character for the scale, either 'C' for Celsius or F for Fahrenheit. The class should have a constructor that sets each instance variable (assume zero degrees if no temp value is specified and Celsius if no scale is specified), and it should include the following methods: 1. two accessor methods: one to return the degrees Celsius and the other to return the degrees Fahrenheit-use the following formulas to write the two methods: DegreesC = 5 (degreesF- 32)/9 DegreesF(9 (degreesc) /5) 32 2. three mutator methods: one to set the value, one to set the scale (F or C), and one to set both: a comparison method: it should return -1 if the invoking temperature is less than the argument temperature, 0 if they are equal and 1 if the invoking temperature is greater than the argument one: and 4. a toString method: returns a String representing the calling Temperature object. The numeric value of the temperature should be rounded to the nearest tenth of a degree. For example, System.out.println (new Temperature (98.164555, F)I/should print: 98.2 F Then write a driver program called TempTester that tests all the methods from the Temperature class. Example tests: 0.0 degrees C 32.0 degrees F, -40.0 degrees C40.0 degrees F, and 100.0 degrees C 212.0 degrees F

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!