Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pls keep the codes simple and don't add anything unnecessarily. Thanks in Advance! Lab Tasks Problem Develop a Java application that can be used to
Pls keep the codes simple and don't add anything unnecessarily. Thanks in Advance!
Lab Tasks Problem Develop a Java application that can be used to obtain and convert temperature between Fahrenheit vs Celsius. The following sections explain the problem solving steps for this problem. Part 1: Practicing Problem Analysis, Design, and Coding Step 1. Problem Statement Design and implement a class for a Temperature object that is capable of reporting its temperature in either Fahrenheit or Celsius. This class should have one instance variable called degree, which contains the Fahrenheit temperature. The Temperature class should have the following public methods: Temperature(double d): the constructor that will receive the input Fahrenheit degree getFahrenheit(): returns the temperature in Fahrenheit getCelsius(); returns the temperature in Celsius: getCelsius() method has to convert the stored temperature to Celsius before returning it. An expression for converting Fahrenheit to Celsius is (5 * (F - 32) /9), where F is the temperature in Fahrenheit Design and implement a class for a TemperatureApp object that is capable of handling user inputs and create Temperature object for temperature converting. This class should have the following public methods: readinputConsole(): Read the user input of Fahrenheit degree from console and return a double Tranresant the Sahrenheit temneratural readlnputConsole(): Read the user input of Fahrenheit degree from console and return a double (represent the Fahrenheit temperature) main(): Create an instance of TemperatureApp to read user input of degree and create another instance of Temperature to report the temperatures in both Fahrenheit and Celsius. Step 2: Problem Decomposition This problem can be divided into two classes 1. Temperature class: implement temperature returning methods 2. TemperatureApp class: the input readings and and contain a main() method in which Temperature instances will be created and used Step 3: Problem Design Draw a UML class diagram to describe the design of the Temperature and Temperature App class. Your design should identify the of the class, its attributes (instance variables) and behaviors (methods). Designate which elements will be hidden and which parts of the class will make up its public interface. Step 4: Problem Implementation 4.1 Implement the Temperature class Similar to Lab3, we will use the stepwise refinement approach that we practiced last time 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. 1. Create an Eclipse project named Lab4 and saving the project on your workspace. Then, create the Temperature class. Step 4: Problem Implementation 4.1 Implement the Temperature class Similar to Lab3, we will use the stepwise refinement approach that we practiced last time 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. 1. Create an Eclipse project named Lab4 and saving the project on your workspace. Then, create the Temperature class. 2. Type the Temperature class design specification you developed in Step 3 into a Java comment block at the beginning of the Temperature.java file. This file will be the file you use for defining the Temperature class. You can refer to the template for the comment block in Lab3->Step3b and complete a design specification for Temperature class. 3. Code the declarations for the class's instance variables as well as the constructor method. 4. Code the definition for each method, one at a time. Note: you need to use/import the following two classes at the beginning of .java file for this lab. import java.util.Scanner; import javax.swing.JOptionPane; 4.2 Implement the TemperatureApp class Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1 Create the Temnerature Ann class import javax.swing.JOptionPane; 4.2 Implement the Temperature App class Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1. Create the TemperatureApp class. 2. Type the Temperature App class design specification you developed in Step 3 into a Java comment block at the beginning of the TemperatureApp.java file. You can refer to the template for the comment block in Lab3->Step3b and complete a design specification for TemperatureApp class. 3. Code the readinputFromConsole() method to read the user's input of Fahrenheit degree from console. 4. Code the main() method. 5. Add code to the main method to create and use one TemperatureApp object to read user input, and one Temperature object to report temperature in both Fahrenheit and Celsius. Here is the sample steps for this main method: TemperatureApp app = new TemperatureApp(); double temp = app.read InputFromConsole(); Temperature tempobj = new Temperature(temp); System.out.println("The temperature is " + tempObj.getFahrenheit() + degree Fahrenheit"); System.out.println("The temperature is + tempobj.getCelsius() + degree Celsius"); 6. Complete the documentation for your program. Add useful comments to your code that will make your program more readable A good rule might be that you should be able to read your TemperatureApp app = new TemperatureApp(); double temp = app.readInputFromConsole(); Temperature tempObj = new Temperature(temp); System.out.println("The temperature is " + tempobj.getFahrenheit() + degree Fahrenheit"); System.out.println("The temperature is " + tempobj.getCelsius () + degree Celsius"); 6. Complete the documentation for your program. Add useful comments to your code that will make your program more readable. A good rule might be that you should be able to read your program two years from now and still understand what it does. You are recommended to add code comments before the method definition such as method descriptions, inputs/outputs of methods, pseudocode if any. Also, try to add comment inside the method body. Step 5: Testing In this part, we will test our developed program in the previous steps. You are required to run the compiled of your program with different set of inputs (temperature degree in Fahrenheit) and capture the screenshots of the outputs of your program. Here is a sample output of this part: 2 Problems @ Javadoc E. Declaration Console XStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started