Java关于JOptionPane的题目求解
发布网友
发布时间:2022-06-24 18:16
我来回答
共1个回答
热心网友
时间:2023-10-11 22:11
可以参考我写的:
String hotelName = JOptionPane.showInputDialog("please input Hotel Name");
String roomType = JOptionPane.showInputDialog("please input room Type");
switch(hotelName) {
case "Romodo":
switch(roomType) {
case "S":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 100, "output tip", 1);
break;
case "D":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 120, "output tip", 1);
break;
case "K":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 130, "output tip", 1);
break;
default:
JOptionPane.showMessageDialog(null, "roon type error", "output tip", 0);
break;
}
break;
case "Haven Inn":
switch(roomType) {
case "S":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 90, "output tip", 1);
break;
case "D":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 100, "output tip", 1);
break;
case "K":
JOptionPane.showMessageDialog(null, "price in dollars is:" + 120, "output tip", 1);
break;
default:
JOptionPane.showMessageDialog(null, "roon type error", "output tip", 0);
break;
}
break;
default:
JOptionPane.showMessageDialog(null, "price in dollars is unknown", "output tip", 1);
break;
}