Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

my code runs but gives no output at all can you please check why.Please use netbeans and send me the output screenshots also.also please check

my code runs but gives no output at all can you please check why.Please use netbeans and send me the output screenshots also.also please check if my code alligns with the questions requirements properly and if you feel any change is required please make it in my code and attach the new code also
public class LoanPaymentCalculator extends Application {
public static void main(String[] args){
launch(args);}
public void start(Stage primary_stage){
primary_stage.setTitle("College Loan Payoff Calculator App");
GridPane display = prepare_display();
addingWidgetsInTheDisplay(display);
Scene s = new Scene(display,400,250);
s.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
primary_stage.setScene(s);
primary_stage.show();}
private GridPane prepare_display(){
GridPane display = new GridPane();
display.setPadding(new Insets(20,20,20,20));
display.setVgap(8);
display.setHgap(10);
return display;}
public void addingWidgetsInTheDisplay(GridPane display){
TextField loan_input = new TextField();
loan_input.setPromptText("Enter The Loan Amount");
loan_input.getStyleClass().add("text-field"); // Correct class name
GridPane.setConstraints(loan_input,0,0);
TextField rate_input = new TextField();
rate_input.setPromptText("Enter The Interest Rate Amount");
rate_input.getStyleClass().add("text-field"); // Correct class name
GridPane.setConstraints(rate_input,0,1);
ToggleGroup term_Toggle = new ToggleGroup();
for(int x =5; x =30; x = x +5){
RadioButton time_Button = new RadioButton(x +" years");
time_Button.setToggleGroup(term_Toggle);
time_Button.getStyleClass().add("radio-button"); // Correct class name
GridPane.setConstraints(time_Button,(x/5)-1,2);
display.getChildren().add(time_Button);
}
Button calculate_button = new Button("Calculate");
calculate_button.getStyleClass().add("calculate-button"); // Correct class name
GridPane.setConstraints(calculate_button,0,3);
Label result_label = new Label();
result_label.getStyleClass().add("result-label"); // Correct class name
GridPane.setConstraints(result_label,0,4);
calculate_button.setOnAction(e -> handlingCalculation(loan_input,rate_input,term_Toggle,result_label));
display.getChildren().addAll(loan_input,rate_input,calculate_button,result_label);
}
private void handlingCalculation(TextField loan_input,TextField rate_input, ToggleGroup term_Toggle, Label result_label){
try{
double loan_amount = Double.parseDouble(loan_input.getText());
double interest_rate = Double.parseDouble(rate_input.getText());
double term_selected = Integer.parseInt(((RadioButton)term_Toggle.getSelectedToggle()).getText().split("")[0]);
double monthly_payment = CalculatingMonthlyPayment(loan_amount,interest_rate,term_selected);
result_label.setText("Your monthly payment is $"+ String.format("%.2f", monthly_payment));
} catch(NumberFormatException ex){
result_label.setText("Invalid input, please enter again (numeric value)");
}
}
private double CalculatingMonthlyPayment(double loan_amount, double interest_rate, double term){
double interest_monthly = interest_rate /100/12;
double monthly_term = term *12;
return (loan_amount * interest_monthly)/(1- Math.pow(1+ interest_monthly, -monthly_term));
}
}
style.css:
.text-field {
-fx-font-size: 16;
}
.radio-button {
-fx-font-size: 16;
-fx-text-fill: #333;
-fx-padding: 510;
-fx-background-color: #f0f0f0;
-fx-border-color: #ccc;
-fx-border-width: 1;
-fx-border-radius: 5;
}
.calculate-button {
-fx-background-color: #4CAF50;
-fx-text-fill: white;
-fx-padding: 1020;
-fx-border-radius: 5;
}
.result-label {
-fx-font-size: 18;
-fx-text-fill: #2E7D32;
}
image text in transcribed

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago