Design and implement Java program as follows: 1) Implement converter class hierarchy as follows: a. Converter...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Design and implement Java program as follows: 1) Implement converter class hierarchy as follows: a. Converter class which includes: Private attribute for input of data type double ■ Default constructor with no parameter which sets input to Double.NaN Overloaded constructor with input for parameter ■ Get and set methods for input attribute ■ Method convert() which returns input value b. TemperatureConverter class which is a child of Converter and includes: ■ Constructors which call parent constructors ■ Overridden convert() method to convert input (Fahrenheit temperature) to Celsius and returns the value. If the instance has no input value, it should return Double.NaN ⚫ Use the following formula for conversion: C = ((F-32)*5)/9 c. DistanceConverter class which is a child of Converter and includes: ■ Constructors which call parent constructors ■ Overridden convert() method to convert input (distance in miles) to distance in kilometers and returns the value. If the instance has no input value, it should return Double.NaN d. Use the following formula for conversion: KM = M * 1.609 2) Implement GUIConverter class using JFrame and JPanel as follows: a. GUI will have 3 buttons: "Distance Converter", "Temperature Converter", and "Exit". Welcome to Conte Distance Converter Temperature Converter Ext b. When user clicks Exit, the program will terminate c. When user clicks Distance Converter, an input dialog will pop up where user can type value and click OK: Welcome to Converter Input ? Input miles distance to convert 3.1 Converter OK Cancel Exit d. Once user clicks OK, message dialog will pop up: vert() Welco Message i 3.1 Miles equals 4.9879 Kilometers OK When user clicks on Temperature button, an input dialog will pop up to input value and then when clicks OK, the message dialog with pop up with converted result: Welcome to Converter Input ? Input fahrenheit temperature to convert 32 Converter OK Cancel Welcome to Converter Exit х Message i 32 F equals 0.0 C e Converter OK Exit f. SUGGESTIONS: ■ For the input dialog you can use JOptionPane.showInputDialog The ActionListener for each Converter button should create the appropriate Converter child instance, set the input, and call its convert() method ■ For the pop up with converted value you can use JOptionPane.showMessageDialog Style and Documentation: Make sure your Java program is using the recommended style such as: ■ Javadoc comment up front with your name as author, date, and brief purpose of the program Design and implement Java program as follows: 1) Implement converter class hierarchy as follows: a. Converter class which includes: Private attribute for input of data type double ■ Default constructor with no parameter which sets input to Double.NaN Overloaded constructor with input for parameter ■ Get and set methods for input attribute ■ Method convert() which returns input value b. TemperatureConverter class which is a child of Converter and includes: ■ Constructors which call parent constructors ■ Overridden convert() method to convert input (Fahrenheit temperature) to Celsius and returns the value. If the instance has no input value, it should return Double.NaN ⚫ Use the following formula for conversion: C = ((F-32)*5)/9 c. DistanceConverter class which is a child of Converter and includes: ■ Constructors which call parent constructors ■ Overridden convert() method to convert input (distance in miles) to distance in kilometers and returns the value. If the instance has no input value, it should return Double.NaN d. Use the following formula for conversion: KM = M * 1.609 2) Implement GUIConverter class using JFrame and JPanel as follows: a. GUI will have 3 buttons: "Distance Converter", "Temperature Converter", and "Exit". Welcome to Conte Distance Converter Temperature Converter Ext b. When user clicks Exit, the program will terminate c. When user clicks Distance Converter, an input dialog will pop up where user can type value and click OK: Welcome to Converter Input ? Input miles distance to convert 3.1 Converter OK Cancel Exit d. Once user clicks OK, message dialog will pop up: vert() Welco Message i 3.1 Miles equals 4.9879 Kilometers OK When user clicks on Temperature button, an input dialog will pop up to input value and then when clicks OK, the message dialog with pop up with converted result: Welcome to Converter Input ? Input fahrenheit temperature to convert 32 Converter OK Cancel Welcome to Converter Exit х Message i 32 F equals 0.0 C e Converter OK Exit f. SUGGESTIONS: ■ For the input dialog you can use JOptionPane.showInputDialog The ActionListener for each Converter button should create the appropriate Converter child instance, set the input, and call its convert() method ■ For the pop up with converted value you can use JOptionPane.showMessageDialog Style and Documentation: Make sure your Java program is using the recommended style such as: ■ Javadoc comment up front with your name as author, date, and brief purpose of the program
Expert Answer:
Answer rating: 100% (QA)
The Java code is given below and Comments are used to include stepbystep instructions The Sample Performance has come to an end Converter Class public class Converter private double input Private attr... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
There is only one java file for all the coding of this assignment allowed. Must be designed under the following: package ConverterGui; public class ConverterGui { and then as requested: Designand...
-
1. Our Play has (14.4/9.86) days of sales tied up in receivables, which is much (higher/lower) than the industry average. It takes Our Play (less/more) time to collect cash from its customers than it...
-
Hyram Company, which is located in State A, had an average annual payroll of $850,000 for the three 12-month periods ending on June 30, 2014 (the computation date for the tax year 2015). As of June...
-
Evaluate the definite integral. Use a graphing utility to verify your result. 173 -2 ex+1 7- ex+1 dx
-
George Oppenheimer, an agent for Wellington Farms of Massachusetts, Inc., had contacted Mark Kiriakou from the Capital Area Food Bank regarding an order for frozen turkey meat. In an exchange of...
-
In problem 89 in Chapter 9 and problem 74 in Chapter 10, the initial basis and the adjusted basis of Emelio and Charitas assets were determined as of December 31, 2011. During 2012, they have the...
-
16. Brenda's Balloon Shop is a price taker, and the table below shows its costs of production. Use it to answer the following questions: Output (balloons Total Cost (dollar per hour) per hour) 0 4 1...
-
Farm Fresh Ltd is a manufacturer of farm equipment that is sold by a network of distributors across Australia and New Zealand. The Service Division manufactures spare parts for the various models of...
-
Problem 6 (20 points) You have learned how to analyze a transaction (event). Each transaction affects financial statement items and thus financial ratios. Since financial ratios affect how a firm...
-
Which is a benefit of after-tax contributions to an HSA? After-tax contributions reduce wages reported on Form W-2, box 1. Contributions are exempt from FICA tax. Contributions may be made until the...
-
A circular conducting loop with a radius of 0.1 m is placed in a uniform magnetic field of 0.5 T. The magnetic field is changing at a rate of 0.02 Ts. The loop has a total resistance of 5 Q. (a)...
-
Suppose you will invest $1,600 each year at the interest rate of 9.4%, beginning one year from now Assuming the interest rate compounds annually, what will be the total future value of these...
-
Explain, briefly, the three strategic approaches to competitive advantages.
-
Given the Hill cipher's encryption key, k - 1 7 determine the corresponding decryption key.
-
When you encountered social media forces aimed at collecting information from you that might help politicians or advertisers in their targeted campaigns (Advertisement) What kind of information did...
-
Four GWU students have been selected to taste food sold by 3 different food trucks labeled as food truck A, B and C on H & 22nd Streets every Monday for 3-weeks. For each student, food trucks are...
-
Write a program to display all possible solutions for the Eight Queens puzzle in a scroll pane, as shown in Figure 22.16. For each solution, put a label to denote the solution number. Solution 1...
-
Write a program to display a recursive tree as shown in Figure 18.20. 1 Enter an order: Enter an order: Enter an order: Enter an order: 5 (b) (a)
-
Write a program that prompts the user to enter a string and displays the string in reverse order. Enter a string: ABCD The reversed string is DCBA JEnter
-
(a) Determine the coherence area for a mercury arc lamp at 6330 at a distance of \(1 \mathrm{~m}\) from the source. Assume that the output aperture is \(3 \mathrm{~mm}\) and that the beam is...
-
Assume an InGaAsP-InP laser diode that has a resonator cavity equal to \(250 \mu \mathrm{m}\). The peak radiation is at \(\lambda=1.55 \mu \mathrm{m}\). The refractive index of InGaAsP is 4. The...
-
Let \(\boldsymbol{x}\) be a random variable with a standard normal distribution \(\varphi(t)\). Find (a) (b) P{0 x 1.42}. P{-0.73x0}. (c) P{-1.37 x2.01}. (d) (e) (f) (g) P{0.65 x 1.26}....
Study smarter with the SolutionInn App