我正在开发一个锻炼程序,该程序在用户通过 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");
}
}
当我运行程序时,我显示的第一个和第二个 if 语句按预期工作。但是,当它转到我的第三个 if 语句时,它失败了。基本上,我输入了所需的年龄和锻炼,但是当它问我输入“胸部”的组时,代码就终止了。
我的问题可能是 JOptionPane 没有显示消息或之前的代码吗?
谢谢