Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Advanced Java Programming with Object-Oriented Programming Design VERY IMPORTANT NOTE, PLEASE READ BEFORE ANSWERING THE QUESTION BELOW!!: Because I'm in an advanced Java class that

Advanced Java Programming with Object-Oriented Programming Design

VERY IMPORTANT NOTE, PLEASE READ BEFORE ANSWERING THE QUESTION BELOW!!: Because I'm in an advanced Java class that must use Object-Oriented Programming Design in all assignments, the answer for the question below MUST contain private variables, at least 2 CLASSES, accessors and mutators for the private variables. You can use any other additional other object-oriented design (OOD) concepts if you want to but private variables, least 2 CLASSES, accessors and mutators for the private variables are a must! I've seen answers to the question below already posted, however they don't utilize object-oriented design (OOD) concepts such as a private variables, least 2 CLASSES, accessors and mutators for the private variables etc, which is required for this advanced Java programming class. So please answer the question meet the requirements for this question. Basically, I need advanced Java object-oriented design concepts for simple programs so here's to hoping this works out and if it does, I'll give a thumbs up, I promise!!! Also I have included some code from Excercise 12.12 to help you help me.

Question:(Temperature-Conversion Modification) Enhance the temperature-conversion application of Exercise 12.12 by adding the Kelvin temperature scale. The application should also allow the user to make conversions between any two scales. Use the following formula for the conversion between Kelvin and Celsius (in addition to the formula in Exercise 12.12): Kelvin = Celsius + 273.15

OK here is some code below, don't forget I that code for the modified temperature conversion program MUST, I repeat MUST, contain private variables, at least 2 CLASSES, accessors and mutators for the private variables:

//import java.text.*; provides classes and interfaces for handling text, dates, numbers, and messages in a manner independent of natural languages. import java.awt.event.*; /**import java.awt.event.ActionListener; is for processing an action event implements this interface, and the object created with that class *is registered with a component, using the component's addActionListener method. When the action event occurs, that object's actionPerformed method * is invoked. */ import java.awt.event.ActionListener; //import javax.swing.JFrame; adds support for the JFC/Swing component architecture and is an extended version of java.awt.Frame. import javax.swing.JFrame; //import javax.swing.JPanel; is a generic lightweight container. import javax.swing.JPanel; /**import javax.swing.JButton; is an implementation of a "push" button. Also, buttons can be controlled to some degree, by Actions * and using an Action with a button has many benefits beyond directly configuring a button. */ import javax.swing.JButton; /**import javax.swing.JLabel; can show either text, an image, or both. Label's contents are aligned by setting the vertical and horizontal *alignment in its display area. */ import javax.swing.JLabel; //import javax.swing.JTextField; is a component which allows the editing of a single line of text. import javax.swing.JTextField; public class TemperatureConversion extends JFrame { //Private variables declared. private static int K; private static int M; //Getter and setter methods for K. public int getK() {

return K;

}

public void setK(int K) {

this.K = K;

} //Getter and setter methods for M. public int getM() {

return M;

}

public void setM(int M) {

this.K = K;

} private JPanel panel; private JButton farenheitButton; private JTextField farenheitField; private JLabel displayLabel, outputLabel; String input; double farenheit; double celcius;

public TemperatureConversion() { super ("Convert Farenheit to Celcius"); displayPanel(); add(panel); // TemperatureConversion textfield = new TemperatureConversion(); super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); super.setSize(400,200); super.setVisible(true); } private void displayPanel() { displayLabel = new JLabel ("Hello!!Please enter your Fahrenheit temperature.:"); farenheitField = new JTextField(10); farenheitButton = new JButton ("Convert to Celcius"); outputLabel = new JLabel (""); farenheitButton.addActionListener(new TemperatureConversionMain()); panel = new JPanel(); //panel.setLayout(new GridLayout(3,6)); panel.add(displayLabel); panel.add(farenheitField); panel.add(farenheitButton); panel.add(outputLabel); } class TemperatureConversionMain implements ActionListener { public void converFtoC(ActionEvent event) { input = farenheitField.getText(); farenheit = Double.parseDouble(input); celcius = (5*farenheit - 160)/9; outputLabel.setText(" Farenheit in Celcius " +farenheit+" is "+celcius); }

@Override public void actionPerformed(ActionEvent event) { converFtoC(event); } }

public static void main(String args[]) { TemperatureConversion textfield = new TemperatureConversion(); } }

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

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago