Q4 (a) (b) (c) Answer Q4(a) - Q4(c) based on the GUI application in Figure Q4(a) and the incomplete program codes in Fig
Posted: Tue Jul 12, 2022 8:21 am
Q4 (a) (b) (c) Answer Q4(a) - Q4(c) based on the GUI application in Figure Q4(a) and the incomplete program codes in Figure Q4(b). import java.awt.*; import java.awt.event.*; import javax.swing. *; } BMI Type your Height and weight Height: Weight: public class BMI implements ActionListener( //Write Swing GUI component declaration private final JFrame frame; public BMI () { //Write code statements to set up GUI components computeButton.addActionListener (this); frame = new JFrame ("BMI"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE) ; } Compute Figure Q4(a) } X frame.setLayout (new BorderLayout()); frame.add (bmiLabel, BorderLayout. NORTH); frame.add (center, BorderLayout.CENTER); frame.add (computeButton, BorderLayout. SOUTH); frame.pack(); frame.setVisible (true); public void actionPerformed (ActionEvent event) { //write code statements to //Handle clicks on compute button to calculate the BMI //Read height and weight data from text fields public static void main (String args[]) { BMI qui new BMI (); Figure Q4(b) Identify the GUI components in Figure Q4(a) and write the swing GUI components declaration statements for the program. (4 marks) Write code statements to set up the GUI components as depicted in Figure Q4(a). (10 marks) Write the method implementation for action Performed (). The formula to calculate Body Mass Index (BMI) is given as follows: weight BMI = x 703 height2 (6 marks)