loops - 如何让我的 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");
}
}
解决方案
推荐阅读
- matplotlib - 使用任意法线转换为 3d 的 matplotlib 2d 补丁的方向与 quiver 给出的方向不匹配
- javascript - 页面未聚焦时停止倒计时
- google-chrome-extension - 将 HTMLImageElement 传递给 tf.fromPixels() 函数
- python - 在 Python3 中使用单元测试进行单元测试
- node.js - 启动 mongodb 时出现 TransientTransactionError
- python-3.x - ElementNotVisibleException:消息:尝试单击 youtube 搜索中的顶部视频时出现元素不可交互错误
- node.js - 错误:/lib/x86_64-linux-gnu/libm.so.6:版本“GLIBC_2.27”
- electron - 在不同的端口上运行 Electron UI
- openstack - Openstack热模板:浮点数作为输入参数
- java - JAR、Fat JAR、Executable JAR 之间的区别