Question: (a) Write a class DialogBox containing the following methods: Input the NZD Amount (i) inputNZDAmount : which displays a dialog box asking user to Input

 (a) Write a class DialogBox containing the following methods: Input the

(a) Write a class DialogBox containing the following methods: Input the NZD Amount (i) inputNZDAmount : which displays a dialog box asking user to "Input the NZD Amount:"and finally returns the input as a real number OK Cancel Before the returning the input, ask the user to confirm using a dialog box, which contains The input is: cuser input>, is it correct?", where"user input" is the input of the user. If the user does not confirm "yes", return zero. Copy the class, including import statement(s), as the answers to this part. Sect an Opticn The input is: 20, is it correct? Yes | Cancel (ii) checkNZDAmount 0 : which calls inputNZDAmount 0 to get the NZD amount to check and nothing is returned. The NZD amount should be greater than zero. If not so, display the error message The NZD amount should be greater than zero" and then call inputNZDAmount to get the NZD amount again until it is correct. You need use a loop to achieve this. Copy the method as the answers to this part. iThe NZD amount should be greater than zero (iii) ma in ( ) : which creates a DialogBox object and calls the method checkNZDAnount () fr testing. Copy the method as the answers to this part [10] (b) Write a class Conversion containing the following methods: (i) constructor : which builds the frame shown on the right side. The frame consists of a text field for inputting a NZD amount, a label with 10 spaces for an equivalent HKD amount, and a button to start the calculation. Declare any necessary attributes in the class and add appropriate action listeners for future use. Copy the class, including import statement (s), as the answers to this part Calculate (ii) actionPerformed ) : which performs the calculation and puts the result on the label when the button is pressed. You can assume one NZD is equivalent to 55 HKD. You can assume a valid real number is entered in the textfield. Copy the method as the answers to this part. 67.87 Calculate (iii) main which creates a Conversion object and sets it visible for testing. Copy the method as the answers to this part 120]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!