JOptionPane not displaying message properly

33 Views Asked by At

I am working on a workout program which displays workout exercises after the user inputs the desired workout exercises through the GUI (JOptionPane).

String name = JOptionPane.showInputDialog("Welcome to the workout and dietary health plan app, Enter your name");
        
        int age = Integer.parseInt(JOptionPane.showInputDialog("Hello " + name + ", what is your age? "));
        
        if(age < 60 && age > 15) {
            String typeAdvice = JOptionPane.showInputDialog("You are the right age to use this app, would you like advice on a workout plan, or a diet plan?");
            if(typeAdvice.contains("workout") || typeAdvice.contains("Workout")) {
                String group = JOptionPane.showInputDialog("What group would you like to workout?");
                if(group.contains("Chest") || group.contains("chest")) {
                    JOptionPane.showInputDialog(null,  "Chest Workouts: Bench Press, Incline Dumbbell Press, Bar Dips, Standing Cable Chest Fly");
                }
            }

When I run the program , the first and second if statement I show works as expected. However, when it goes to my third if statement it fails. Basically, I input the required age and workout, but when it asks me the group I enter "chest", and the code just terminates.

Could my problem be with the JOptionPane not displaying the message or the code before it?

Thank You

0

There are 0 best solutions below