Design and implement a class for Temperature objects that are capable of reporting their temperature in either Fahrenheit or Celsius. A formula for converting Fahrenheit to Celsius is: C = (5*(F-32)/9)
The class should have one field (attribute) called degreesF, which contains the Fahrenheit temperature, and public methods called getFahrenheit(), which returns the temperature in Fahrenheit, and getCelsius(), which returns the temperature in Celsius. There should also be a public constructor method that takes the Fahrenheit temperature as a parameter.
Test your class definition by implementing a main() method that creates Temperature instances and displays their temperature values. Your program should produce something like the following output in the Java console:
The Fahrenheit temperature of thermometer1 is 20.0 degrees.
The Celsius temperature of thermometer1 is -6.67 degrees.
The Fahrenheit temperature of thermometer2 is 98.6 degrees.
The Celsius temperature of thermometer2 is 37.0 degrees.
You can use different values than the ones shown to test your program if you like. Also, don't worry about the exact format of the numbers. It is OK if your output displays a different number of decimal places.
This problem can be solved using only one class, the Temperature class, which will implement the temperature conversion. It will contain a main() method in which Temperature instances will be created and used.
/*
* Class Name: Temperature
* Author: (your name here)
*
* Description:
* (Describe the purpose of the class here.
* Use multiple lines, if necessary.)
*
*/
Step 4. Use the stepwise refinement approach to code and test the Temperature class. Here's a sequence of appropriate steps, after each of which you should compile and run your program:
Read the From the Java Library Section of Chapter 2 of Java, Java, Java, 3E (pp. 91-94), and then incorporate code into your main() method that allows the user to input the values for temperatures. Follow the examples in the book of inputting numbers using the Scanner class. The input values read in main should be passed to the constructor method of the Temperature class.
When your assignment is complete, add some comments to the beginning of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution. Undocumented bugs are worse than documented bugs. If you have undocumented bugs we will assume that you did an inadequate job of testing your code, and you will lose additional points.
Submit your source code file (Temperature.java) as an email attachment to: ttao@umassd.edu. Use the subject line CIS-180 HW#2 in your email. Your UML class diagram may either be submitted in class (hardcopy), or included as a second email attachment (softcopy) with your source code. Make sure you send your homework to the proper place. Homework sent to the wrong address may not receive credit!There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.