Question: // java public class DonorGUI extends JFrame { public static final String ELIGIBLE = Eligible! ; public static final String NOT_ELIGIBLE = Sorry, not eligible.
// java public class DonorGUI extends JFrame { public static final String ELIGIBLE = "Eligible!"; public static final String NOT_ELIGIBLE = "Sorry, not eligible."; public static final String INPUT_ERROR = "Error - enter positive numbers"; private JPanel rootPanel; private JButton checkEligibilityButton; private JTextField weightTextField; private JTextField ageTextField; private JLabel resultLabel; DonorGUI() { this.setContentPane(rootPanel); pack(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); // TODO add a listener for the checkEligibilityButton // This should verify that the user has entered a positive number // in both the weightTextField and ageTextField JTextField // If either or both are not valid, the resultLable should // display the INPUT_ERROR text. // If both weight and age are positive numbers, use the data // to decide if the user is eligible to be a blood donor. // To be eligible, a person must be 17 or older, // AND weigh 110 lbs or more. // Display the ELIGIBLE text if they are eligible. // Display the NOT_ELIGIBLE text if they are not eligible. } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
