JavaFX Loan Calculator Application Design and Implementation

Verified

Added on  2025/09/03

|9
|693
|205
AI Summary
Desklib provides solved assignments and past papers for students.
Document Page
Table of Contents
Design........................................................................................................................................2
Code:..........................................................................................................................................3
Evaluation:.................................................................................................................................7
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Design
The design of the application window is created so that the user can easily access the
application. The application window contains the text field for the income and the years. A
button is also included in the window application. The text area is also included in the
window.
Figure 1 design
Document Page
Code:
// text area is imported for creating the text area in the window.
import javafx.scene.control.TextArea;
// label is imported in orderto give the labels in the files.
import javafx.scene.control.Label;
// application class is imported for interfave intialization
import javafx.application.Application;
// stage is import to get select the stage in the window.
import javafx.stage.Stage;
// geometery class is used to calculate the position.
import javafx.geometry.Pos;
// borderpane is imported to give the window in the application window.
import javafx.scene.layout.BorderPane;
// textfileds are imported to get the innput from the user.
import javafx.scene.control.TextField;
// the scene is imported.
import javafx.scene.Scene;
// Hbox is imported to the create the horizontal box in the application wndow.
import javafx.scene.layout.HBox;
// createing the button in order to perform the function.
import javafx.scene.control.Button;
// scroll pane is imported in order to the scroll down the window.
import javafx.scene.control.ScrollPane;
// the class is create in which all the objects will be created
public class Calculatepayment extends Application {
// object of TextArea is created to get the text area in the application window.
TextArea blnk = new TextArea();
// object of textfield is create to get the loan amount from the user.
TextField loanamount = new TextField();
Document Page
// object of textfield is create to get the years from the user.
TextField no_of_yr = new TextField();
@Override
// method created to intial the stage.
public void start(Stage initialStage) {
// the size of the column is set.
no_of_yr.setPrefColumnCount(2);
// set the value in the prefcolumncount.
loanamount.setPrefColumnCount(7);
// set the prefcolumncount 30for the space.
blnk.setPrefColumnCount(30);
// button object is created to calculate the tax.
Button dt = new Button("Calculate");
// create the object of HBox.
HBox hxobj = new HBox();
// mentioning the alignment of the application.
hxobj.setAlignment(Pos.CENTER);
// hxobj space setting
hxobj.setSpacing(9);
// the labels are introduced in the application window
hxobj.getChildren().addAll(new Label("Loan amount"), loanamount, new
Label("Number of Years"), no_of_yr, dt);
// the object of the scollpane is created.
ScrollPane scrlobj = new ScrollPane(blnk);
// the object of BorderPane is created
BorderPane bpobj = new BorderPane();
//the bpobject value.
bpobj.setTop(hxobj);
// the text area is aligned in the centre.
bpobj.setCenter(blnk);
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
dt.setOnAction(b -> {
showDetails();
});
//the object is scene is created.
Scene temp = new Scene(bpobj);
// the initialStage is intialized.
initialStage.setScene(temp);
// the title page
initialStage.setTitle("Calculate Payments");
// show the starting stage.
initialStage.show();
}
// craete the methos showDetails
private void showDetails(){
// the string type variables is introduced.
String output;
// intializing thre variable
output = "";
// the double type varible is created in order to calculate tax.
double flag;
double monthlypay;
// print the output
output+="Interest rate Monthly payment Final Payment \n";
// for loop to calculate the interest.
for (double i = 5.0; i <= 8; i += 0.125){
// Calculating flag
flag=i/1200;
Document Page
// claulating the tax
monthlypay=Double.parseDouble(loanamount.getText())*flag/(1-1/Math.pow(1+flag,
Double.parseDouble(no_of_yr.getText())*12));
// output is saved.
output+=String.format("%-34.3f%-30.2f%-8.3f\n",i, monthlypay,
(monthlypay*12)*Double.parseDouble(no_of_yr.getText()));
}
// set the calulate output.
blnk.setText(output);
}
public static void main(String[] args) {
launch(args);
}
}
Output:
Figure 2 Output
Document Page
Evaluation:
Evaluation of UI
The User interface is created accordingly to the brief. The user can enter the amount and
number of years in the text fields. The user can get the output by clicking on the calculate
button.
Figure 3 Evaluation of UI
Evaluation of the Calculation
The system is successfully collecting the interest rate, monthly payment and the Final
payment with respect to the inserted amount and years. The outputs are shown below which
prove the correct result.
Figure 4 Evaluation of the Calculation (1)
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Figure 5 2 Evaluation of the Calculation (2)
Figure 6 2 Evaluation of the Calculation (3)
Evaluation of the table:
The table is shown the results in the proper alignment the details of the monthly and final
payment are successfully shown in the table format.
Document Page
Figure 7 Evaluation of the table
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]