How can I make this program able to implement listener for the editable text field:
/////////////////////////////// KiloConverter.java //////////////////////////
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class KiloConverter extends JFrame {
// constant for converting km to miles
static final double KM_TO_MILES = 0.6214;
// important components that needs to be accessed throughout the program
private JTextField input, output;
// constructor initializing GUI
public KiloConverter() {
// passing title to super class
super("Kilometer Converter");
// will exit on click
setDefaultCloseOperation(EXIT_ON_CLOSE);
// creating a panel
JPanel panel1 = new JPanel();
// creating components for first row, adding to the above panel
JLabel label1 = new JLabel("Enter a distance in kilometers");
input = new JTextField(15);
JButton calc = new JButton("Calculate");
panel1.add(label1);
panel1.add(input);
panel1.add(calc);
// creating another panel
JPanel panel2 = new JPanel();
// creating components for second row, adding to the above panel
output = new JTextField(15);
output.setEditable(false); // not editable
output.setBackground(Color.LIGHT_GRAY);
JLabel label2 = new JLabel("Miles");
JButton exit = new JButton("Exit");
panel2.add(output);
panel2.add(label2);
panel2.add(exit);
// adding first panel to the north of window, second to the south
add(panel1, BorderLayout.NORTH);
add(panel2, BorderLayout.SOUTH);
// adding action listeners to the buttons
calc.addActionListener(new CalculateButtonListener());
exit.addActionListener(new ExitButtonListener());
// using compact size
pack();
}
// private inner class representing action to be performed when calculate
// button is clicked
private class CalculateButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
// getting input, parsing to double, converting to miles, displaying
// with 3 digits precision
double km = Double.parseDouble(input.getText());
double miles = km * KM_TO_MILES;
output.setText(String.format("%.3f", miles));
}
}
// private inner class representing action to be performed when exit
// button is clicked
private class ExitButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
//simply exiting
System.exit(0);
}
}
}
// /////////////////////// Driver.java /////////////////////////////////
//public driver program to run the KiloConverter class
public class Driver {
public static void main(String[] args) {
KiloConverter converter = new KiloConverter();
converter.setVisible(true);
}
}
In: Computer Science
Problem 17-48 Flexible Budget (LO 17-5)
Oak Hill Township operates a motor pool with 20 vehicles. The motor pool furnishes gasoline, oil, and other supplies for the cars and hires one mechanic who does routine maintenance and minor repairs. Major repairs are done at a nearby commercial garage. A supervisor manages the operations.
Each year, the supervisor prepares a master budget for the motor pool. Depreciation on the automobiles is recorded in the budget to determine the costs per mile.
The following schedule presents the master budget for the year and for the month of July.
| OAK HILL TOWNSHIP | |||||||||||||||||||
| Motor Pool | |||||||||||||||||||
| Budget Report for July | |||||||||||||||||||
| Annual Master | One-Month | Over- or | |||||||||||||||||
| Budget | Master Budget | July Actual | (Under-) Budget | ||||||||||||||||
| Gasoline | $ | 81,000 | $ | 6,750 | $ | 8,515 | $ | 1,765 | |||||||||||
| Oil, minor repairs, parts, and supplies | 7,200 | 600 | 761 | 161 | |||||||||||||||
| Outside repairs | 5,400 | 450 | 90 | (360 | ) | ||||||||||||||
| Insurance | 12,000 | 1,000 | 1,050 | 50 | |||||||||||||||
| Salaries and benefits | 63,600 | 5,300 | 5,300 | 0 | |||||||||||||||
| Depreciation | 52,800 | 4,400 | 4,620 | 220 | |||||||||||||||
| Total cost | $ | 222,000 | $ | 18,500 | $ | 20,336 | $ | 1,836 | |||||||||||
| Total miles | 900,000 | 75,000 | 94,500 | ||||||||||||||||
| Cost per mile | $ | 0.2467 | $ | 0.2467 | $ | 0.2152 | |||||||||||||
| Number of automobiles | 20 | 20 | 21 | ||||||||||||||||
The annual budget was based on the following assumptions:
Automobiles in the pool: 20.
Miles per year per automobile: 45,000.
Miles per gallon per automobile: 20.
Gas per gallon: $1.80.
Oil, minor repairs, parts, and supplies per mile: $0.008.
Outside repairs per automobile per year: $270.
The supervisor is unhappy with the monthly report, claiming that it unfairly presents his performance for July. His previous employer used flexible budgeting to compare actual costs to budgeted amounts.
Required:
a. What is the gasoline monthly flexible budget and the resulting amount over- or underbudget? (Use miles as the activity base.) (Do not round intermediate calculations. If the amounts are equal to budget, select "No change".)
|
b. What is the monthly flexible budget for the oil, minor repairs, parts, and supplies and the amount over- or underbudget? (Use miles as the activity base.) (Do not round intermediate calculations. If the amounts are equal to budget, select "No change".)
|
\
c. What is the monthly flexible budget for salaries and benefits and the resulting amount over- or underbudget? (Do not round intermediate calculations. If the amounts are equal to budget, select "No change".)
|
In: Accounting
Below are percentages for annual sales growth and net sales attributed to loyalty card usage at 74 Noodles & Company restaurants.
| Annual Sales Growth (px;) and Loyalty Card Usage
(px; of Net Sales) (n = 74 restaurants) |
|||||||||||||||||
| Store | Growth% | Loyalty% | Store | Growth% | Loyalty% | ||||||||||||
| 1 | -8.0 | 0.5 | 38 | 7.3 | 2.4 | ||||||||||||
| 2 | -7.5 | 2.5 | 39 | 7.5 | 1.6 | ||||||||||||
| 3 | -6.4 | 2.4 | 40 | 7.8 | 1.9 | ||||||||||||
| 4 | -5.2 | 1.8 | 41 | 8.0 | 2.1 | ||||||||||||
| 5 | -5.0 | 2.1 | 42 | 8.1 | 1.6 | ||||||||||||
| 6 | -1.7 | 1.6 | 43 | 8.1 | 1.3 | ||||||||||||
| 7 | -0.7 | 2.1 | 44 | 8.5 | 2.5 | ||||||||||||
| 8 | -0.5 | 2.2 | 45 | 8.5 | 2.3 | ||||||||||||
| 9 | -0.5 | 1.2 | 46 | 8.6 | 1.4 | ||||||||||||
| 10 | -0.5 | 2.6 | 47 | 8.7 | 0.8 | ||||||||||||
| 11 | 0.3 | 2.6 | 48 | 8.8 | 2.7 | ||||||||||||
| 12 | 0.9 | 0.8 | 49 | 9.0 | 2.1 | ||||||||||||
| 13 | 0.9 | 1.9 | 50 | 9.1 | 1.4 | ||||||||||||
| 14 | 1.2 | 1.3 | 51 | 9.2 | 2.1 | ||||||||||||
| 15 | 1.7 | 2.2 | 52 | 10.5 | 2.0 | ||||||||||||
| 16 | 1.8 | 2.4 | 53 | 10.8 | 1.7 | ||||||||||||
| 17 | 1.9 | 2.5 | 54 | 10.8 | 1.4 | ||||||||||||
| 18 | 2.0 | 1.9 | 55 | 11.0 | 0.9 | ||||||||||||
| 19 | 4.0 | 0.8 | 56 | 11.3 | 1.8 | ||||||||||||
| 20 | 4.3 | 2.1 | 57 | 11.4 | 1.2 | ||||||||||||
| 21 | 4.5 | 1.4 | 58 | 11.6 | 0.7 | ||||||||||||
| 22 | 4.7 | 2.2 | 59 | 11.8 | 1.5 | ||||||||||||
| 23 | 4.9 | 1.5 | 60 | 11.8 | 2.1 | ||||||||||||
| 24 | 5.2 | 1.8 | 61 | 13.5 | 1.2 | ||||||||||||
| 25 | 5.2 | 2.4 | 62 | 14.1 | 1.5 | ||||||||||||
| 26 | 5.3 | 1.6 | 63 | 14.3 | 1.9 | ||||||||||||
| 27 | 5.4 | 1.2 | 64 | 15.1 | 0.7 | ||||||||||||
| 28 | 5.5 | 2.0 | 65 | 15.5 | 2.1 | ||||||||||||
| 29 | 5.6 | 2.6 | 66 | 15.9 | 1.6 | ||||||||||||
| 30 | 5.7 | 2.0 | 67 | 16.0 | 0.9 | ||||||||||||
| 31 | 5.9 | 1.5 | 68 | 16.2 | 2.6 | ||||||||||||
| 32 | 6.0 | 1.9 | 69 | 16.2 | 1.4 | ||||||||||||
| 33 | 6.4 | 2.3 | 70 | 17.8 | 2.2 | ||||||||||||
| 34 | 6.4 | 0.6 | 71 | 18.8 | 2.1 | ||||||||||||
| 35 | 6.6 | 1.9 | 72 | 18.9 | 1.3 | ||||||||||||
| 36 | 6.6 | 2.3 | 73 | 19.8 | 0.6 | ||||||||||||
| 37 | 6.7 | 1.2 | 74 | 24.0 | 1.7 | ||||||||||||
(b) Find the correlation coefficient.
(Round your answer to 3 decimal places. A negative value
should be indicated by a minus sign.)
r
_________
(c-1) To test the correlation coefficient for
significance at α = 0.01, fill in the following.
(Use the rounded value of the correlation
coefficient from part b in all calculations. For final answers,
round tcalc to 3 decimal places and the
p-value to 4 decimal places. Negative values should be
indicated by a minus sign.)
| tcalc | |
| p-value | |
In: Statistics and Probability
WTVCA Inc. may invest in new equipment and there are three possible outcomes with the following new present values of $48,570, $33,214 and $15,989, respectively. The outcomes have probabilities of 0.3, 0.5, and 0.2, respectively. Calculate risk (measured by the standard deviation) associated with this proposal.
In: Economics
WEIGHT E(r) Sigma
ASSET A: 0.3 1.487% 6.344%
ASSET B: 0.5 2.078% 6.353%
ASSET C: 0.2 1.66% 7.616%
ρAB=0.313 ρBC=0.374 ρAC=0.321
1. What is the standard deviation and expected return of the portfolio?
In: Finance
|
POOR |
FAIR |
GOOD |
EXCELLENT |
|
|
PROBABILITY |
0.1 |
0.4 |
0.3 |
0.2 |
|
Batch |
- $200,000 |
$1,000,000 |
$1,200,000 |
$1,300,000 |
|
Custom |
$100,000 |
$300,000 |
$700,000 |
$800,000 |
|
Group Technology |
- $1,000,000 |
-$500,000 |
$500,000 |
$2,000,000 |
What is the EVPI = Expected Value of Perfect Information?
In: Statistics and Probability
A call centre manager in an insurance company is interested in knowing the pattern of calls for cancellation. The number of cancellation calls an agent receives per hour follows a Poisson distribution with a mean of 1.2.
What is the probability that an agent receives more than two cancellation calls for the next three hours?
a)0.3 b)0.823 c)0.7 d)0.177
In: Statistics and Probability
AVP of a manufacturing firm that produces two products has to decide (1) How much capacity to build? (2) Whether to invest in dedicated or flexible resources, or a portfolio consisting of both dedicated and flexible systems. The VP received the following forecasting for the demand of each product. Year 1–2 Year 3–6 Volume Volume Probability Product A 500,000 200,000 0.7 600,000 0.3 Product B 200,000 200,000 0.3 600,000 0.7 A dedicated line can produce 300,000 annually and its cost is $30 million. Flexible systems are supplied at chunks; each has an annual production capacity of 50,000 units and costs $7 million. The revenues from each product sold are $40. (a) Calculate the optimal capacity—type and quantity. (b) What is the optimal solution if the cost of a dedicated line that can produce 200,000 annually is $15 million? (c) What is the optimal solution if the cost of a dedicated line that can produce 300,000 annually is $40 million?
In: Accounting
21. According to the sticky-wage theory of the short-run aggregate supply curve, if workers and firms expected prices to rise by 3 percent, but instead prices rise by 1 percent, then a. employment and production rise. b. employment rises and production falls. c. employment falls and production rises. d. employment and production fall. 22. The aggregate demand and aggregate supply model implies monetary neutrality a. only in the short run. b. only in the long run. c. in both the short run and the long run. d. in neither the short run nor long run. 23. In the early 1930s in the United States, there was a a. large increase in output. In the early 1940s there was also a large increase in output. b. large increase in output. In the early 1940s there was a large decrease in output. c. large decrease in output. In the early 1940s there was a large increase in output. d. large decrease in output. In the early 1940s there was also a large decrease in output. 24. If households spend $90 of every $100 of after tax income, then the government purchases multiplier is a. 3 b. 5 c. 9 d. 10
In: Economics
Vivian and Noelle are traveling in opposite directions from their starting point. Noelle is traveling 5mph faster than Vivian. given that the distance between them after 8 hours is 136 miles, determine the velocity of each one of them
In: Math