I am using IntelliJ IDEA with JavaFX to build a travel expensive calculator, but somehow it
wouldn't calculate total expensive? It was working until I add the TextFieldListener because I need to make sure user
only input either mile driven or airfareCost. Please help me figure out what I did wrong.
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
TextField field1, field2, field3, field4, field5, field6;
Button submitButton, cancelButton;
@Override
public void start(Stage primaryStage) throws Exception{
Label label1 = new Label ("(1) Number of days on the trip");
Label label2 = new Label ("(2) Transportation cost (choose one only)");
Label label3 = new Label ("Airfare Cost ");
Label label4 = new Label ("Miles driven ");
Label label5 = new Label ("(3) Conference registration cost ");
Label label6 = new Label ("(4) Lodging Cost (per night) ");
Label label7 = new Label ("(5) Food cost (total) ");
Label TotalExpensive = new Label("Total expenses: ");
Label TotalExpensiveResult = new Label(" ");
Label TotalCost = new Label("How much you own: ");
Label TotalCostResult = new Label(" ");
field1 = new TextField();
field2 = new TextField();
field3 = new TextField();
field4 = new TextField();
field5 = new TextField();
field6 = new TextField();//all textfield
submitButton = new Button ("Submit"); //Create submit button
submitButton.setDisable( true);
cancelButton = new Button ("Cancel"); //Create Cancel button
HBox hBox = new HBox(20, label1, field1);
HBox hBox1 = new HBox(10, label2);
HBox hBox2 = new HBox(15, label3, field2);
HBox hBox3 = new HBox(10, label4, field3);
HBox hBox4 = new HBox(12, label5, field4);
HBox hBox5 = new HBox(32, label6, field5);
HBox hBox6 = new HBox(75, label7, field6);
HBox hBox7 = new HBox(20, submitButton, cancelButton);
HBox hBox8 = new HBox(20, TotalExpensive, TotalExpensiveResult);
HBox hBox9 = new HBox(20, TotalCost, TotalCostResult);
hBox.setAlignment(Pos.BASELINE_RIGHT); //Alignment
hBox1.setAlignment(Pos.BASELINE_LEFT);
hBox2.setAlignment(Pos.BASELINE_RIGHT);
hBox3.setAlignment(Pos.BASELINE_RIGHT);
hBox4.setAlignment(Pos.BASELINE_RIGHT);
hBox5.setAlignment(Pos.BASELINE_RIGHT);
hBox6.setAlignment(Pos.BASELINE_RIGHT);
hBox7.setAlignment(Pos.CENTER);
hBox8.setAlignment(Pos.BASELINE_LEFT);
hBox9.setAlignment(Pos.BASELINE_LEFT);
hBox1.setPadding(new Insets(0,0,15,0));
hBox3.setPadding(new Insets(0,0,15,0));
hBox7.setPadding(new Insets(15,0,0,0));
hBox8.setPadding(new Insets(0,0,15,0));
hBox9.setPadding(new Insets(0,0,15,0));
TextFieldListener listener = new TextFieldListener();
field1.textProperty().addListener(listener);
field2.textProperty().addListener(listener);
field3.textProperty().addListener(listener);
field4.textProperty().addListener(listener);
field5.textProperty().addListener(listener);
field6.textProperty().addListener(listener);
GridPane gridPane = new GridPane ();
gridPane.add(hBox, 0, 0);
gridPane.add(hBox1, 0, 1);
gridPane.add(hBox2, 0, 2);
gridPane.add(hBox3, 0, 3);
gridPane.add(hBox4, 0, 4);
gridPane.add(hBox5, 0, 5);
gridPane.add(hBox6, 0, 6);
gridPane.add(hBox7, 0, 7);
gridPane.add(hBox8, 0, 8);
gridPane.add(hBox9, 0, 9);
gridPane.setAlignment(Pos.CENTER);
gridPane.setPadding( new Insets(20, 20, 20, 20));
gridPane.setVgap( 10);
gridPane.setHgap( 10);
primaryStage.setTitle("Travel Expenses Calculator");
primaryStage.setScene(new Scene (gridPane));
primaryStage.show();
submitButton.setOnAction(event ->
{
double days = Double.parseDouble(field1.getText());
double airFare = Double.parseDouble(field2.getText());
double miles = Double.parseDouble(field3.getText());
double ConregCost = Double.parseDouble(field4.getText());
double lodgingCost = Double.parseDouble(field5.getText());
double foodCost = Double.parseDouble(field6.getText());
TotalExpensiveResult.setText(" " + ( airFare+ foodCost + ConregCost + (days * lodgingCost)) );
});
}
private class TextFieldListener implements ChangeListener<String>
{
@Override
public void changed(ObservableValue<? extends String> source, String oldValue, String
newValue)
{
String numTrip = field1.getText();
String airFare = field2.getText();
String miles = field3.getText();
String confCost = field4.getText();
String lodgingCost = field5.getText();
String foodCost = field6.getText();
if (airFare.trim().equals( "") )
{
submitButton.setDisable(numTrip.trim().equals( "") ||miles.trim().equals( "") || confCost.trim().equals( "")||
lodgingCost.trim().equals( "")|| foodCost.trim().equals( ""));
}
else if (miles.trim().equals( "") )
{
submitButton.setDisable(numTrip.trim().equals( "") ||airFare.trim().equals( "") || confCost.trim().equals( "")||
lodgingCost.trim().equals( "")|| foodCost.trim().equals( ""));
}
else
{
submitButton.setDisable( true);
}
}
};
public static void main(String[] args) {
launch(args);
}
}
In: Computer Science
In: Operations Management
Michael is an environmentalist earning HK$40,000 per month. He went to Syria for environmental protection work last year. However, Syria was in war and Michael’s hotel room was bombed during his stay. He lost his left arm and right leg. After being transferred back to Hong Kong, he has to seek assistance from his wife for many daily activities, such as washing, feeding, and toileting. However, he can still work in a sheltered workshop and earns $850 per month. Suppose Michael had long-term care insurance before he went to Syria. Should the insurance company pay monthly benefit to Michael? Select one:
a. Yes, because Michael lost his left arm and right leg.
b. Yes, because Michael is suffering from dysfunction and cannot perform at least 3 daily activities.
c. Yes, because Michael’s monthly salary decreases from HK$40,000 to HK$850.
d. No, because the dysfunction was caused by the act of war.
e. No, because Michael is employed and is still able to work.
Katherine is covered by medical expense insurance. Which of the following items is likely to be excluded from her insurance policy?
Select one:
a. She gets hit by a falling potted plant, causing her to receive dental care for fixing the front tooth.
b. She is diagnosed of stage 3 lung cancer and receives radiology treatment.
c. She is seriously injured in a car accident and get admitted to intensive care unit.
d. She goes to South Korea for cosmetic surgery to boost up her self-confidence.
e. All of the above are excluded from her medical expense insurance policy.
In: Operations Management
Give a brief summary of each and explain why they are the most important
Benefit 3 A higher minimum wage could reduce government welfare spending. If low-income workers earned more money, their dependence on, and eligibility for, government benefits would decrease. The Center for American Progress reported in 2014 that raising the federal minimum wage by 6% to $10.10 would reduce spending on the Supplemental Nutrition Assistance Program (SNAP, formerly known as food stamps) by 6% or $4.6 billion. [9] The Economic Policy Institute determined that by increasing the minimum wage to $10.10, more than 1.7 million Americans would no longer be dependent on government assistance programs. They report the increase would shave $7.6 billion off annual
Cost 3 Raising the minimum wage would increase the price of consumer goods. A 2013 article by the Federal Reserve Bank of Chicago stated that if the minimum wage is increased, fast-food restaurants would pass on almost 100% of their increased labor costs on to consumers and that other firms may do the same. [2] A 2015 University study found that raising the wage of fast food restaurant employees to $15 or $22 per hour would result in a price increase of 4.3% and 25% respectively, or a reduction in product size between 12% and 70%: "a hamburger would be much smaller," the researchers stated. [53] NBC News found that the price of a cup of coffee went up by 10 to 20% in Oakland, California, after a 36% minimum wage hike in the city to government spending on incomesupport programs. $12.25. The report also found a 6.7% rise in coffee prices in Chicago after the minimum wage rose to $10. [54] The Alberta Hotel and Lodging Association (Canada) found that a "sudden and significant increase to the minimum wage" would result in "[i]ncreased prices for food & beverage, guest rooms and meeting facilities." [55]
In: Economics
1- A is Trading and Tourism Company.
2- B is the owner of a Building
A interred with B in to an investment Contract where A will take
the building as investment which is owned by B and will turn to
Hotel. It was agreed that, A prior to invest will take the approval
from B on the plans and drawings. A sent the plans and the drawing
to B for his approval. It was agreed that within a week if there
were no answer from any of the parties on the correspondences of
the other for any approval, therefore, it would mean that approval
has been granted. A has started to do all the changes according to
the plans and the drawings after a week from sending the plans.
After a month A has received the reply from B with changes made in
the plans and drawings. A has ignored the reply and continue the
changes according to his plans. B was not happy and has demanded A
to stop the work in the building and deliver the building at the
same conditions he received it. A has replied to B that he has
invested in the building according to the contract and if he wants
the building back he has to pay the cost of his investments and the
remedies of the damages that he has incurred. B has refused his
demands and asked A to pay for all the repairs and damages caused
to his building.
You have been contacted as mediator between the A and B Please
answer the following:
1. What kind of relation between A and B?
2. Identify the responsibility for both parties and their civil
rights.
3. What is the real problem between the two parties?
4. Does B have the right to stop work in the building and does A
have the right to ignore B’s changes in the plans?
5. What action A should take to make B accept the plans and
drawings and to finish the work?
6. In your conclusion, you should provide a good solution for A and
B to continue to work together without going to litigation.
In: Economics
correlation measures the degree to which two variables are related to one another.
Here are the definitions of the three possibilities:
Values range from -1 to 1. The closer to -1 or 1 the stronger the correlation. The closer to 0 the weaker it is. Correlation is a term that refers to the strength of a relationship between two variables where a strong, or high, correlation means that two or more variables have a strong relationship with each other while a weak or low correlation means that the variables are hardly related. Correlation analysis is the process of studying the strength of that relationship with available statistical data.
Example: A recent study of marriage and education found a strong negative correlation between the level of education and the divorce rate. Data from the National Survey of Family Growth show that as education level increases among women, the divorce rate for first marriages decreases.
I did a study asking community members how safe they felt in their neighborhood (on a scale of 1 to 5, with 1 = not at all safe to 5=extremely safe). I also asked the same community members how often they used their community park (on a scale of 1=never to 5=always). I ran the statistics and my correlation is .789. Is this a negative or positive correlation? And what does it show (write it out like in the example above about the direction of each variable and what that means)
In: Statistics and Probability
You operate your own small building company and have decided to bid on a government contract to build a pedestrian walkway in a national park during the coming winter. The walkway is to be of standard government design and should involve no unexpected costs. Your present capacity utilization rate is moderate and allows sufficient scope to understand this contract, if you win it. You calculate your incremental costs to be $268,000 and your fully allocated costs to be $440,000. Your usual practice is to add between 60% and 80% to your incremental costs, depending on capacity utilization rate and other factors. You expect three other firms to also bid on this contract, and you have assembled the following competitor intelligence about those companies.
|
Issue |
Rival A |
Rival B |
Rival C |
|
Capacity Utilization |
At full capacity |
Moderate |
Very low |
|
Goodwill Considerations |
Very concerned |
Moderately concerned |
Not concerned |
|
Production Facilities |
Small and inefficient plant |
Medium sized and efficient plant |
Large and very efficient plant |
|
Previous Bidding Pattern |
Incremental cost plus 35-50% |
Full cost plus 8-12% |
Full cost plus 10-15% |
|
Cost Structure |
Incremental costs exceed yours by about 10% |
Similar cost structure to yours |
Incremental costs 20% lower but full costs are similar to yours |
|
Aesthetic Factors |
Does not like winter jobs or dirty jobs |
Does not like messy or inconvenient jobs |
Likes projects where it can show its creativity |
|
Political Factors |
Decision maker is a relative of the buyer |
Decision maker is seeking a new job |
Decision maker is looking for a promotion |
Show all of your calculations and processes. Describe your answers in three- to five-complete sentences.
A.) What price would you bid if you must win the project?
In: Economics
M.D. is 69 years old, visits her GP for a repeat prescription of perindopril arginine 2.5 mg. She was diagnosed with heart failure and heart disease 1 year ago (LVEF < 40%) after a myocardial infarction and was started on carvedilol 12.5 mg. M.D. moved into a retirement village 1 year ago after the death of her husband. She is an active member of the walking group, but over the last 3 weeks she has had increased shortness of breath and fatigue after a steady 20 minute walk at the park. Since then she has reduced her level of physical activity and has also noticed swelling in her ankles despite her usual fluid tablets. She tells you that she has been having packaged soups instead of regular meals, because she finds it convenient, and is drinking more water than previously recommended (< 1.5 L/day was recommended after her heart failure diagnosis). Her medical history includes dyslipidemia, osteoarthritis, stable ischemic heart disease, and hypertension. Her current medicines (all once daily) are carvedilol 12.5 mg, aspirin 81 mg, atorvastatin 20 mg, celecoxib 200 mg, controlled-release isosorbide mononitrate 60 mg and furosemide 20 mg. M.D. currently weighs 70 kg (up by 4 kg from last visit 6 months ago) and her blood pressure is 140/82 mmHg. Serum biochemistry (urea, creatinine and electrolytes) was normal when tested 6 weeks ago. LDL was 100 and HDL was 52. Her estimated creatinine clearance was 60 mL/min.
Discuss how the chronic care model can be used to assist M.D
In: Nursing
M.D. is 69 years old, visits her GP for a repeat prescription of perindopril arginine 2.5 mg. She was diagnosed with heart failure and heart disease 1 year ago (LVEF < 40%) after a myocardial infarction and was started on carvedilol 12.5 mg. M.D. moved into a retirement village 1 year ago after the death of her husband. She is an active member of the walking group, but over the last 3 weeks she has had increased shortness of breath and fatigue after a steady 20 minute walk at the park. Since then she has reduced her level of physical activity and has also noticed swelling in her ankles despite her usual fluid tablets. She tells you that she has been having packaged soups instead of regular meals, because she finds it convenient, and is drinking more water than previously recommended (< 1.5 L/day was recommended after her heart failure diagnosis). Her medical history includes dyslipidemia, osteoarthritis, stable ischemic heart disease, and hypertension. Her current medicines (all once daily) are carvedilol 12.5 mg, aspirin 81 mg, atorvastatin 20 mg, celecoxib 200 mg, controlled-release isosorbide mononitrate 60 mg and furosemide 20 mg. M.D. currently weighs 70 kg (up by 4 kg from last visit 6 months ago) and her blood pressure is 140/82 mmHg. Serum biochemistry (urea, creatinine and electrolytes) was normal when tested 6 weeks ago. LDL was 100 and HDL was 52. Her estimated creatinine clearance was 60 mL/min.
Discuss two (2) self-care management recommendations for M.D.
In: Nursing
M.D. is 69 years old, visits her GP for a repeat prescription of perindopril arginine 2.5 mg. She was diagnosed with heart failure and heart disease 1 year ago (LVEF < 40%) after a myocardial infarction and was started on carvedilol 12.5 mg. M.D. moved into a retirement village 1 year ago after the death of her husband. She is an active member of the walking group, but over the last 3 weeks she has had increased shortness of breath and fatigue after a steady 20 minute walk at the park. Since then she has reduced her level of physical activity and has also noticed swelling in her ankles despite her usual fluid tablets. She tells you that she has been having packaged soups instead of regular meals, because she finds it convenient, and is drinking more water than previously recommended (< 1.5 L/day was recommended after her heart failure diagnosis). Her medical history includes dyslipidemia, osteoarthritis, stable ischemic heart disease, and hypertension. Her current medicines (all once daily) are carvedilol 12.5 mg, aspirin 81 mg, atorvastatin 20 mg, celecoxib 200 mg, controlled-release isosorbide mononitrate 60 mg and furosemide 20 mg. M.D. currently weighs 70 kg (up by 4 kg from last visit 6 months ago) and her blood pressure is 140/82 mmHg. Serum biochemistry (urea, creatinine and electrolytes) was normal when tested 6 weeks ago. LDL was 100 and HDL was 52. Her estimated creatinine clearance was 60 mL/min.
List two (2) factors that may have exacerbated M.D.’s heart failure and what suggestions you would provide for M.D.
In: Nursing