Question

Objective: To implement the programming languages features discussed in class and to develop a program that...

Objective: To implement the programming languages features discussed in class and to develop a program that uses Graphical User Interfaces (GUI) that provides a friendly environment for users.

Project Assignment

Design and implement a Hotel Reservation System. The hotel has two types of rooms. One is regular room that has two beds. Another is deluxe room that has two beds and a safe. The regular room price is $120 per night. The deluxe room is $130 per night. A safe cost additional $20 per night (only for deluxe room). The hotel has 10 rooms. This system should allow an agent to input a customer name, select a room type, using the safe box or not as well as arrival and departure dates. It should also provide the capability to calculate the total charge and display it on the screen. The hotel reservation system must satisfy the following requirements:

  1. An interface should be developed to allow an agent to input required information.

  2. The system must test for required fields

  3. The system must show the use of arrays

  4. A person reserves a room via reserve method. This method returns an integer indicating the room number. If a customer tried to reserve a room, but the rooms are sold out, and error message should be displayed.

  5. If a customer reserved a room the person’s name, arrive time, departure date, room number,and total charge should be displayed.

  6. Must use and run in Java NetBeans 8.0.2 or higher (Please specify when you submit your code)

  7. Turn in the all project folder using the blackboard digital drop box

  8. Code must follow proper programming standards (comments, indentation, proper variables names, etc.)

  9. No partial credit will be given if the program does not run.

  10. Please submit your project folder in a zip file

  11. No late assignment will be accepted

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:


import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
*
*/
public class Hotel extends javax.swing.JFrame {

/**
* Creates new form Hotel
*/
public int rooms=10;
public Hotel() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
name = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
choice = new javax.swing.JComboBox<>();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
arrival = new javax.swing.JTextField();
dept = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Reservation");

jLabel1.setText("Name");

jLabel2.setText("Room Type");

choice.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Regular Room", "Deluxe Room without Safe", "Deluxe Room with Safe" }));

jLabel3.setText("Arrival Date (dd-mm-yyyy)");

jLabel4.setText("Departure Date (dd-mm-yyyy)");

jButton1.setText("BOOK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(name)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(dept, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
.addComponent(arrival, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(choice, 0, 183, Short.MAX_VALUE))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(124, 124, 124)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(choice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(arrival, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(dept, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(36, 36, 36)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(95, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {   
if(rooms>=1){
int ch=choice.getSelectedIndex();
int rate=0;
switch(ch){
case 0:
rate=120;
break;
case 1:
rate=130;
break;
case 2:
rate=150;
break;
}
int ar_dd=Integer.parseInt(arrival.getText().trim().split("-")[0]);
int dep_dd=Integer.parseInt(dept.getText().trim().split("-")[0]);
int cost=(((dep_dd-ar_dd)>0)?(dep_dd-ar_dd):1)*rate;
JOptionPane.showMessageDialog(this,"Room is Booked Total Charge is $"+cost);
}
else
{
JOptionPane.showMessageDialog(this,"Rooms Not Available");
}// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Hotel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Hotel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Hotel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Hotel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Hotel().setVisible(true);
}
});
}

// Variables declaration - do not modify   
private javax.swing.JTextField arrival;
private javax.swing.JComboBox<String> choice;
private javax.swing.JTextField dept;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JTextField name;
// End of variables declaration   
}

OUTPUT:

Reservation Jim Room Type Arrival Date (dd-mm-yyyy) Departure Date (dd-mm-yyyy) 27-04-2019 Deluxe Room without Safe 22-04-201

Message 1 Room is Booked Total Charge is $650 OK

Reservation Jim Name Room Type Arrival Date (dd-mm-yyyy) Departure Date (dd-mm-yyyy)27-04-2019 Deluxe Room without Safe Messa

Add a comment
Know the answer?
Add Answer to:
Objective: To implement the programming languages features discussed in class and to develop a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use Case Modeling APPENDIX-A Online Hotel Reservation System RichOS hotels owner Mr. Tompkins wanted an online...

    Use Case Modeling APPENDIX-A Online Hotel Reservation System RichOS hotels owner Mr. Tompkins wanted an online reservation system (HORSE) for his new hotel located in Antalya. The hotel has two types of rooms: regular and suit. In order to make a reservation or cancel any other, the clients (persons or travel agency) must logon the system. The clients should register to the system through their names, e-mail and telephone information. Clients will be able to query the availability of the...

  • Round Tree Manor is a hotel that provides two types of rooms with three rental classes: Super Saver, Deluxe, and Business. The profit per night for each type of room and rental class is as follows:...

    Round Tree Manor is a hotel that provides two types of rooms with three rental classes: Super Saver, Deluxe, and Business. The profit per night for each type of room and rental class is as follows: Rental Class Super Saver Deluxe Business Room Type I (Mountain View) $35 $40 - Type II (Street View) $25 $35 $45 Round Tree's management makes a forecast of the demand by rental class for each night in the future. A linear programming model developed...

  • Plz someone answer my database questions post Exercise I (50 pts): This exercise deals with a...

    Plz someone answer my database questions post Exercise I (50 pts): This exercise deals with a database that stores information abhout Hotel Management System. Customer (C email, name, country) Payment (Invoice id. C email, payment method, date) Invoice (Invoice id, starus, invoice description) Has (Bill id, Invoice id) Bill (Invoice id, Bill id, amount, Bname, type, date, reservation id) Reservation (Hotel id., room id. C email, date, period, reservation id) Rooms(Hotel id, room id. price, category) lotel (Hotel id, H...

  • Plz someone answer my database questions post Exercise I (50 pts): This exercise deals with a...

    Plz someone answer my database questions post Exercise I (50 pts): This exercise deals with a database that stores information abhout Hotel Management System. Customer (C email, name, country) Payment (Invoice id. C email, payment method, date) Invoice (Invoice id, starus, invoice description) Has (Bill id, Invoice id) Bill (Invoice id, Bill id, amount, Bname, type, date, reservation id) Reservation (Hotel id., room id. C email, date, period, reservation id) Rooms(Hotel id, room id. price, category) lotel (Hotel id, H...

  • Your page will simulate a reservation form for a hotel stay. It should include the following:...

    Your page will simulate a reservation form for a hotel stay. It should include the following: Name à Text field Email à Text field Number of nights à Text field (of size 3) Type of room? à Select box with options for Regular ($100), Deluxe ($150), Suite ($250) Would you like to join our Frequent Travellers Club? If you join, we will take $50 off your first order. à Checkbox Write the function that will confirm what the user requested....

  • Project 3 Objective: The purpose of this lab project is to exposes you to using menus,...

    Project 3 Objective: The purpose of this lab project is to exposes you to using menus, selection writing precise functions and working with project leaders. Problem Specification: The PCCC Palace Hotel needs a program to compute and prints a statement of charges for customers. The software designer provided you with the included C++ source and you are asked to complete the code to make a working program using the given logic. The function main () should not change at all....

  • Design and implement an Employee Payment System using single inheritance. This system will support three types...

    Design and implement an Employee Payment System using single inheritance. This system will support three types of employees that are technician, engineer and manager. An employee has basic information such as last name, first name, address, telephone number and social security number. Basic operations include set month payment rate, calculate annual salary and actual payment. Tax is deducted at 20% of total payment. The company allows a and overtime pay rate. If a manager does an excellent job the company...

  • Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from...

    Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from the previous assignment and modify it so that it uses an array of Car objects as the principal data structure instead of an ArrayList-of-Car. This is an example of the OOP principle of information hiding as your Car and test classes will not have to be modified at all. Unless you broke encapsulationon the previous assignment, that is   II. Specifications Specifications for all 3...

  • Rationale The focus of the project is to develop your database programming skills. This project will...

    Rationale The focus of the project is to develop your database programming skills. This project will help you get a fair idea of the sales and distribution system in any organization that has a chain of Carrying and Forwarding Agents (CFAs) or super stockists and stockists. You will be able to implement database programming concepts of ADO.NET in VB.NET and ASP.NET to create a real-life, web-based database application. (VB stands for Visual Basic.) Scenario Smooth Pen, Inc., a pen manufacturing...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT