Using an SQLite database your program should be able to create, read, update, and delete room reservations.

Present the user with a menu at the beginning using the console or JOptionPane for example:
Choose a task
1. Add a reservation
2. View a reservation
3. List all reservations
4. Update a reservation
5. Cancel a reservation
Choice: 1
What is your check-in date (YYYY-MM-DD)? 2013-08-02
How many nights will you be staying? 2
How many guests will be staying? 1
We have 1 palace room available at $250 per night. Your total price will be $500.
Type 'yes' to confirm your booking. yes.
Thank you, your reservation number is 2.
If all rooms are booked for a date you should not add a reservation.

You can stop the user from entering a date in the past or prevent them from
entering 0 guests or nights. You could split a party into multiple rooms if they will not fit in 1 room.
You can extend your program to add new rooms to the database. Be creative.
The program should loop until the user asks to quit.

If there are too many guests for an available room you should not add a reservation.

Recommended Answers

All 5 Replies

I'd just buy a system from a schoolkid who had to build it as his homework assignment, no need to create something like that from scratch unless you have a big hotel chain with unique requirements, and then you'd best hire a team of experienced programmers.

commented: Yes i do this is what i have but can't proceeed from here. " import java.sql.*; import java.text.DateFormat; import java.text.SimpleDateFormat; public static void main(String[] args) throws ClassNotFoundException{ Class.forName("org.sqlite.JDBC"); +0

Did you try to make any attempt to do it yet?

commented: Yes i do this is what i have but can't proceeed from here. " import java.sql.*; import java.text.DateFormat; import java.text.SimpleDateFormat; public static void main(String[] args) throws ClassNotFoundException{ Class.forName("org.sqlite.JDBC"); +0

Yes i do this is what i have but can't proceeed from here.
" import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public static void main(String[] args) throws ClassNotFoundException{



    Class.forName("org.sqlite.JDBC");



    Connection conn = null;

    try{
        conn = DriverManager.getConnection("jdbc:sqlite:test1.db");
        System.out.println("connected....");

        Statement statement = conn.createStatement();
        statement.executeUpdate("drop table if exists reservation");
        statement.executeUpdate("create table reservation (Reservation_id integer primary key autoincrement, " +
                "room_id integer, num_of_guests integer, check_in text, check_out text, price real)");
        int rows = statement.executeUpdate("insert into reservation values('1','2', '3', '2013-07-24',  '2013-07-31', '630')"); 
        System.out.println(rows + "rows were Inserted");
        statement.executeUpdate("insert into reservation values('2', '3', '1', '2013-08-02', '2013-08-04', 500)");
        System.out.println(rows + "rows were Inserted");

        PreparedStatement ps = conn.prepareStatement("insert into reservation(room_id, num_of_guests, check_in, check_out, price) values(?, ?, ?, ?, ?)");
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd" );
                ps.setString(3, df.format(Date.valueOf("2013-08-02")));

        statement.executeUpdate("drop table if exists Room");
        statement.executeUpdate("create table Room (Room_id integer primary key autoincrement, " +
                "Style text, max_occupancy integer, Price_per_guest integer)");

        statement.executeUpdate("insert into Room values('2', 'suite', '4', '30.00')");
        System.out.println(rows + "rows were Inserted");
        statement.executeUpdate("insert into Room values('3', 'Palace', '2', '250.00')");
        System.out.println(rows +"rows were Inserted");
    }




        catch (SQLException e) {
            e.printStackTrace();
        }

    }
}

"

can't proceed from here ... what does it do? what is your next step? why can't you proceed.

also: do you understand why it is bad design to allow your main method to throw Exceptions? did you write that code yourself?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.