Answered step by step
Verified Expert Solution
Link Copied!

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!image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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 X ", JOptionPane. QUESTION_MESSAGE); return Double.parseDouble(strInput); Note: Replace with your Full Name. 2. Code the public void showTemperatureByJOptionPane( double fDegree, double cDegree) method to show both Fahrenheit and Celsius degrees using the JOptionPane class. The sample code of this method is below: 11 1 return Double. parseDouble(strinput); Note: Replace with your Full Name. 2. Code the public void showTemperatureByJOptionPane (double fDegree, double cDegree) method to show both Fahrenheit and Celsius degrees using the JOptionPane class. The sample code of this method is below: JOptionPane.showMessageDialog(null, "The temperature is " + fDegree + degree Fahrenheit or + Degree + degree Celsius", "TemperatureApp by ", JOptionPane. INFORMATION_MESSAGE); Note: Replace with your Full Name. 3. Comment out source codes in the main method so far (using the line comment syntax //). Then use readlnputFromJOptionPanel) to read user input. Later call the showTemperatureByJOption Pane() method to report temperature in both Fahrenheit and Celsius. Here is the sample code you can add in the main() method: TemperatureApp app = new TemperatureApp(); double temp app.readInputFromJOptionPane(); Temperature tempObj = new Temperature(temp); app.showTemperatureByJOptionPane(tempObj.getFahrenheit(), tempobj.getCelsius()); 4. Insert additional code comments to Temperature App.java Step 7: Re-test the new application with GUI enhancement You are required to run the compiled of your enhanced program (GUI) with different set of inputs (temperature degree in Fahrenheit) and canture the screenshots of the outputs of your program Step 7: Re-test the new application with GUI enhancement You are required to run the compiled of your enhanced program (GUI) 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: TemperatureApp TemperatureApp Enter the temperature in Fahrenheit: 77 The temperature is 77.0 degree Fahrenheit or 25.0 degree Celsius. Cancel OK OK Submission You need to submit the following results: 1. Capture the screenshot outputs for your program in part 1 (step 5) and part 2 (step 7). Write them into a PDF file named output.pdf. 2. Source code: Submit the exported project Lab4 folder (DO NOT compress it into .zip) to your /your_name/lab4 folder in your class storage

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

Google Analytics 4 The Data Driven Marketing Revolution

Authors: Galen Poll

2024th Edition

B0CRK92F5F, 979-8873956234

More Books

Students also viewed these Databases questions

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago

Question

Discuss the goals of financial management.

Answered: 1 week ago