JavaFX代写 | Programming Assignment 3


Question 1 (22 marks)

Consider the following program below:

(a) Describe what will be shown on the screen when the above program is executed. Sketch a
diagram to illustrate your answer [6 marks]

(b) Modify the build method to add logic to the button; when we click on the button, the
attribute count is incremented by 2 and updated value is shown on the Label. [10 marks]

(c) Consider the JavaFX Application class – it is responsible for managing the lifecycle of a
JavaFX application. Answer the following questions, assuming no main method has been
defined in a JavaFX application:

3 methods are being called throughout the lifecycle. One of them is the init method. List the
other two and explain what functionality they provide. [5 marks]

for eg: The init() is where application initialization is done. It is called every time the
application is initialized/ loaded. It is called only once during the application’s lifecycle.

Question 2 (22 marks)

(a) Write a JavaFX program, called WeightConverter that displays a screen similar to the
one shown below:

The program allows user to enter their weight, in kilograms , and then converts the
value in pounds. Based on their weight in pounds, the user can either belong to
following categories:

Weight less than 160 pounds – Lightweight class
Weight between 160 pounds to 168 pounds – Middleweight class
Weight greater than 168 pounds – Heavyweight class