首页 > 解决方案 > 如何让我的 GUI 出现不止一次并接受该输入

问题描述

嗨,我是编程新手,我需要制作一个程序来回答这个问题,而我目前卡在这个问题上。

提示用户使用数字 1、2 或 3 从菜单中选择与他喜欢的成员资格或额外选项相对应的项目,否则用户输入 0 退出。如果用户选择 1,则再次显示输入框,如果用户随后选择 0,则显示所选会员的成本。如果用户在输入 0 之前从菜单中选择了 extras,则添加 extra 的价格并将其显示给用户。如果用户选择所有三个,则添加三个并向用户显示成本。

我不明白如何让 gui 出现不止一次并且仍然接受输入。

打包在线申请;

导入 javax.swing.JOptionPane;公共类在线申请{

public static void main(String[] args) {
 String result;
  int one=350;
  int two=450;
  int three=550;
 int input;
   String calculations;       
   
  
   result =   JOptionPane.showInputDialog(null,"(1)Basic membership     "+one+" \n(2)Specials          "+two+"\n (3)VIP treatment      "+three+"  \nmake selection.Press 0 to quit",JOptionPane.INFORMATION_MESSAGE);     

  
   input= Integer. parseInt(result);
   
   
 
   
   if(input==1 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+one); 
   if(input==2 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+two);
   if(input==3 && input ==0)JOptionPane.showMessageDialog(null, "Your total cost comes to "+three);
   
   if(input==1 && input==2 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+one+two); 
   if(input==1 && input==3 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+one+three); 
   if(input==2 && input==3 && input==0)   JOptionPane.showMessageDialog(null, "Your total cost comes to 800"+three+two); 
   
   if(input==1 && input==2 && input==3 )JOptionPane.showMessageDialog(null, "Your total cost comes to 1350");

 
    }

  }

标签: loopsif-statementuser-interface

解决方案


推荐阅读