Question
complete the program for the calculation of the total accommodation charges when a customer checks out from the hotel. Applet: import java.awt.*; import java.awt.event.*; import
complete the program for the calculation of the total accommodation charges when a customer checks out from the hotel.
Applet:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
public class HotelCheckOut extends JApplet implements ActionListener {
private final double PRICE_SUITE = 499.00;
private final double PRICE_DOUBLE = 159.00;
private final double PRICE_SINGLE = 99.00;
private JLabel name1, name2, room, quantity, days, currency, exchange, display, result;
private JPanel mainpanel, leftpanel, rightpanel;
private JTextField numSuite, numDoubleRoom, numSingleRoom, numDays, exchangeRate;
private JCheckBox suite, doubleRoom, singleRoom;
private JRadioButton usCurrency, cdnCurrency;
private JButton calculate;
private ButtonGroup group;
public void init() {
mainpanel = new JPanel();
leftpanel = new JPanel();
rightpanel = new JPanel();
name1 = new JLabel(" OKANAGAN");
name2 = new JLabel("HOTEL");
room = new JLabel("Room Type:");
quantity = new JLabel ("Number of rooms:");
days = new JLabel ("Number of days:");
currency = new JLabel ("Currency for Payment:");
exchange = new JLabel ("U.S. Exchange Rate:");
suite = new JCheckBox ("Suite");
doubleRoom = new JCheckBox ("Double Room");
singleRoom = new JCheckBox ("Single Room");
usCurrency = new JRadioButton ("U.S. Currency");
cdnCurrency = new JRadioButton ("Cdn Currency", true);
numSuite = new JTextField ("0");
numDoubleRoom = new JTextField ("0");
numSingleRoom = new JTextField ("0");
numDays = new JTextField("1");
exchangeRate = new JTextField ("");
calculate = new JButton ("Check Out");
display = new JLabel ("Total amount:");
result = new JLabel(" ");
result.setBorder (BorderFactory.createEtchedBorder ());
group = new ButtonGroup ();
group.add(usCurrency);
group.add(cdnCurrency);
exchangeRate.setEditable(false);
calculate.addActionListener(this);
usCurrency.addActionListener(this);
cdnCurrency.addActionListener(this);
mainpanel.setLayout(new GridLayout(1,2));
leftpanel.setLayout(new BoxLayout(leftpanel,BoxLayout.Y_AXIS));
rightpanel.setLayout(new BoxLayout(rightpanel,BoxLayout.Y_AXIS));
leftpanel.add(name1);
leftpanel.add (Box.createRigidArea (new Dimension (0, 21)));
leftpanel.add (room);
leftpanel.add (Box.createRigidArea (new Dimension (0, 9)));
leftpanel.add(suite);
leftpanel.add (Box.createRigidArea (new Dimension (0, 8)));
leftpanel.add(doubleRoom);
leftpanel.add (Box.createRigidArea (new Dimension (0, 8)));
leftpanel.add(singleRoom);
leftpanel.add (Box.createRigidArea (new Dimension (0, 15)) );
leftpanel.add (days);
leftpanel.add (Box.createRigidArea (new Dimension (0, 15)) );
leftpanel.add (currency);
leftpanel.add(usCurrency);
leftpanel.add(cdnCurrency);
leftpanel.add (Box.createRigidArea (new Dimension (0, 18)));
leftpanel.add(display);
rightpanel.add (name2);
rightpanel.add (Box.createRigidArea (new Dimension (0, 22)));
rightpanel.add (quantity);
rightpanel.add (Box.createRigidArea (new Dimension (0, 11)));
rightpanel.add(numSuite);
rightpanel.add (Box.createRigidArea (new Dimension (0, 10)));
rightpanel.add(numDoubleRoom);
rightpanel.add (Box.createRigidArea (new Dimension (0, 10)));
rightpanel.add(numSingleRoom);
rightpanel.add (Box.createRigidArea (new Dimension (0, 15)));
rightpanel.add (numDays);
rightpanel.add (Box.createRigidArea (new Dimension (0, 15)));
rightpanel.add (exchange);
rightpanel.add (Box.createRigidArea (new Dimension (0, 6)));
rightpanel.add(exchangeRate);
rightpanel.add (Box.createRigidArea (new Dimension (0, 40)));
rightpanel.add(result);
rightpanel.add (Box.createRigidArea (new Dimension (0, 15)));
rightpanel.add(calculate);
mainpanel.add(leftpanel);
mainpanel.add(rightpanel);
add(mainpanel);
} // init
public void computePayment() {
// complete this method for the payment.
}
public void actionPerformed (ActionEvent event) {
// complete this method to perform appropriate actions
} // actionPerformed
} // class HotelCheckOut
Here are some specifications to guide your work: Charges for a suite, double-room and single-room are $499.00, S159.00 and $99.00 per day in Canadian Currency respectively. . The CheckOut button is used to trigger the calculation of the total room accommodation charges for the customer in Canadian Currency by default. The customer has an option to pay in U.S currency, and the user needs to input the currency exchange rate for the calculation of the payment in U.S. currency Your applet program should also be intelligent enough to trigger the calculation automatically when the user switches from the payment option in U.S. currency back to Canadian currency
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started