Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please solve this using methods that are stricting from the beginner CSS 1/Java 1/ Programming 1 courses. Thank you! Part 3 A More Sophisticated Object

image text in transcribed

Please solve this using methods that are stricting from the beginner CSS 1/Java 1/ Programming 1 courses. Thank you!

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?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: 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 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, O if they are equal and 1 if the invoking temperature is greater than the argument one; A toString method: returns a String representing the calling Temperature object. The numeric value ofthe temperature should be rounded to the nearest tenth of a degree. For example, System.out.printin(new Temperature(98.164555, F)); //should print: 98.2F 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 C-40.0 degrees F, and 100.0 degrees C-212.0 degrees F

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions