所以我有一个计划,我应该计算在酒店房间停留"x"周的费用.
我希望能够让用户输入"x",但我不确定我会使用什么代码.此外,这是我的代码到目前为止.
public class Hotel extends JFrame
{
int room1 = 0;
int room2 = 0;
int weeks;
int boat = 0;
JPanel p, p1;
JLabel l, l1;
JTextField t, t1;
JButton b;
JCheckBox b1, b2, b3;
Hotel()
{
setTitle("Hotel Room Selection");
setSize(800, 800);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
buildPanel();
add(p);
setVisible(true);
}
void buildPanel()
{
l = new JLabel("Select a room type");
l1 = new JLabel("How many weeks will you be staying?");
b = new JButton("Confirm");
b1 = new JCheckBox("1 bedroom ($600 per …Run Code Online (Sandbox Code Playgroud)