hi,

I'm a beginner in Java and new to NetBeans. I have a project to do where I have to use NetBeans to write a hotel program.
the questions is displayed like this

One of your friends is working behind a room reservation counter helping customers to determine the price of a room in a famous chain of hotels. He is having trouble keeping track of all the options available when it comes to calculating the price of room for a single customer request. He asked you to help him by creating a small system that will automate the task of computing the price of a room. The hotel maintains the following policies:

Hotel Seasons
The hotel is operating throughout the year. The year is divided into three different season’s i.e. normal, low, high:
* High Season: December to January
* Normal Season: September to November and February to May. During the normal season prices are reduced by 15%.
* Low Season: June to August. During the low season prices are reduced by 30%.

During the high season the hotel is calculating rates based on the following rules:

Room Type: The hotel has four different types of rooms:
* King Deluxe: 2000 AED per night per person
* Suite Deluxe: 1000 AED per night per person
* Double Deluxe See View: 600 AED per night per person
* Double Deluxe Garden View: 400 AED per night per person
* Double Economy: 200

Meal Option: The above prices do not include any meals. Meals are available at an extra cost and the prices are described below:

  • Option a) Breakfast only: 170 AED per day per person
  • Option b) Breakfast and Lunch: 250 AED per day per person
  • Option c) Breakfast and Dinner: 300 AED per Day per person
  • Option d) Breakfast, lunch and Dinner: 400 AED per Day per person
    Important Note: The meals are optional. Hotel guests may not require meals.

Satellite Television and Internet Access (optional). Users may choose any combination of choices below.

  • Movie channels: 25 AED per day
  • Sport channels: 50 AED per day
  • Documentary channels: 30 AED per day
  • Internet Access: 20 AED per day

In addition to all the above options the price of the room depends on the number of adults. System users will have to supply the number of adults and the number of children (if any). The hotel offers discount rates for children based on their age:

  • Children between the ages of 14 and 17 will obtain a 15% discount
  • Children between the ages of 8 and 13 will obtain a 50% discount
  • Children below 8 will obtain a 75% discount

Write a java program that will guide the user through all the options described above. The program must be menu operated. That is the system must clearly present all options to the users through the use of text based menus. I.e. lists of choices were the user can pick from a list of predefined options. At all times the system MUST validate user input. If the user had entered an invalid option the system will respond by displaying an appropriate message and then it will terminate execution without requesting any additional details.

If the user has successfully completed all options then the system will present a full analytical report which summarizes all options/choices selected to the user and then it displays the final price.

I've done most of the work but got stuck in putting the boolean to terminate the program when the values entered by the user are wrong also I didn't know how to make the meals and TV channels optional.

I would appreciate anyone who can help me finish this project today because I have to hand it over tomorrow and I really need this mark to pass.

it won't take a lot of time because I already organized everything.
to make it clear this is what I've done so far,

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jasem1;
import console.ConsoleIO;
/**
 *
 * @author HCT
 */
public class Jasem1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        boolean stopProgram;
       stopProgram = false;
        char season;
        double discountamount=0;
      int highseason=1;
      int normalseason=2;
      int lowseason=3;
        double price=0;
        System.out.println("1)High sesson : Starts From December to January"
                + "n2)Normal season : Starts from September to November and February to May"
                + "n3)Low season : Starts from June to August" );
        season=ConsoleIO.readCharacter("please select the season--------->");


        if(season=='1'){
                discountamount=0;
        }
       else if (season=='2'){
            discountamount= price*0.15;
       }

        else if(season=='3'){
            discountamount=price*0.3;}


  else 
        {
                        stopProgram = true;

            System.out.println("ERROR");
            stopProgram = true;
        } 



   char typeofroom;
   double roomprice=0;

   System.out.println("1)•King Deluxe: 2000 AED per night per person"
           + "n2)•Suite Deluxe: 1000 AED per night per person "
           + "n3)•Double Deluxe See View: 600 AED per night per person"
           + "n4)•Double Deluxe Garden View: 400 AED per night per person"
           + "n5)•Double Economy: 200");

   typeofroom=ConsoleIO.readCharacter("Please your type of room");

   if (typeofroom=='1')
   {roomprice=2000*discountamount;}

  else if (typeofroom=='2')
   {roomprice=1000*discountamount;}


   else if (typeofroom=='3')
   {roomprice=600*discountamount;}

   else if (typeofroom=='4')
   {roomprice=400*discountamount;}

   else if (typeofroom=='5')
   {roomprice=200*discountamount;}

    else
                 {
                    System.out.println("ERROR");
                    stopProgram = true;
                 }

   char mealoption;
   int mealprice=0;

   System.out.println("a) Breakfast only: 170 AED per day per person"
           + "nb)Breakfast and Lunch: 250 AED per day per person"
           + "nc)Breakfast and Dinner: 300 AED per Day per person"
           + "nd) Breakfast, lunch and Dinner: 400 AED per Day per person"
           + "ne)Don't order");

   mealoption=ConsoleIO.readCharacter("Please Choose Your Meal");

   if(mealoption=='a')
   {mealprice=170;}

   else if (mealoption=='b')
   {mealprice=250;}

   else if (mealoption=='c')
   {mealprice=300;}

   else if (mealoption=='d')
   {mealprice=400;}

   else if (mealoption=='d')
   {mealprice=0;}

   else System.out.println("ERROR");

   int choice;
   double theprice=0;
   int days;

   System.out.println("1)•Movie channels: 25 AED per day"
           + "n2)•Sport channels: 50 AED per day"
           + "n3)•Documentary channels: 30 AED per day"
           + "n4)•Internet Access: 20 AED per day");

   days=ConsoleIO.readCharacter("Please enter number of days");
   choice=ConsoleIO.readCharacter("Please enter your choice");

   if(choice=='1')
   {theprice=25*days;}

   else if (choice=='2')
   {theprice=50*days;}

   else if (choice=='3')
   {theprice=30*days;}

   else if (choice=='4')
   {theprice=20*days;}


      System.out.println("---------------------------------------------------------------");
         System.out.println("Children Discount");
         System.out.println("---------------------------------------------------------------");
         System.out.println("[a] for Children Between The Ages of 14 and 17 will obtain a 15% Discount");
         System.out.println("[b] for Children Between The Ages of 8 and 13 will obtain a 50% Discount");
         System.out.println("[c] for Children Below 8 will obtain a 75% Discount");
         System.out.println("[d] None");
         System.out.println("---------------------------------------------------------------");

        char ChildrenAge;
        int ChildrenNumber=0;
        int AdultNumber;
        double discountAmount = 0;
        double AdultPrice;
        double ChildrenPrice;
        double finalprice;


         System.out.print("Please Enter The Age of Children --> "); 
         ChildrenAge = ConsoleIO.readCharacter();


        if (ChildrenAge == 'a')
                 {
                     System.out.print("Please Enter The Number of Children --> "); 
         ChildrenNumber = ConsoleIO.readInteger();
                     discountAmount = 0.85*roomprice;
                 }
                 else if (ChildrenAge == 'b')
                 {System.out.print("Please Enter The Number of Children --> "); 
         ChildrenNumber = ConsoleIO.readInteger();
                     discountAmount = 0.50*roomprice;
                 }
                 else if (ChildrenAge == 'c')
                 {System.out.print("Please Enter The Number of Children --> "); 
         ChildrenNumber = ConsoleIO.readInteger();
                     discountAmount = 0.25*roomprice;
                 }

                 else if (ChildrenAge == 'd')
                 {
                     discountAmount = 0;
                 }


        System.out.print("Please Enter The Number of Adult --> "); 
         AdultNumber = ConsoleIO.readInteger();

        AdultPrice = AdultNumber*mealprice + AdultNumber*theprice;
        ChildrenPrice = ChildrenNumber*mealprice*discountAmount + ChildrenNumber*theprice*discountAmount;




        finalprice = roomprice + AdultPrice + ChildrenPrice;

        System.out.println(finalprice);


  System.out.println("Season-->"+discountamount) ;
  System.out.println("Type of room-->"+roomprice) ;
  System.out.println("Meal-->"+mealprice) ;
  System.out.println("Your choice-->"+choice*days) ;
  System.out.println("Children-->"+ChildrenPrice) ;
  System.out.println("Adult-->"+AdultPrice) ; 
  System.out.println("Final Price-->"+finalprice) ;
}}

Writing codes in NetBeans seems really confusing. I really need help guys.

Here is the whole file
http://www.mediafire.com/?5esu3n8r09iggr2

any help would be appreciated.

Recommended Answers

All 3 Replies

Do you have specific problems with your code?
Or do you have specific questions you'd like to ask about it?

but got stuck in putting the boolean to terminate the program when the values entered by the user are wrong

Can you high light the area where you are having the problem with comments that are easy to see.


Please edit your post and wrap the code in code tags. Use the [code] icon above the input box.

hi norm, I don't have problems with the codes themselves its just the way that they are established like for example :

boolean stopProgram;
stopProgram = false;
char season;
double discountamount=0;
int highseason=1;
int normalseason=2;
int lowseason=3;
double price=0;
System.out.println("1)High sesson : Starts From December to January"
+ "\n2)Normal season : Starts from September to November and February to May"
+ "\n3)Low season : Starts from June to August" );
season=ConsoleIO.readCharacter("please select the season--------->");


if(season=='1'){
discountamount=0;
}
else if (season=='2'){
discountamount= price*0.15;
}

else if(season=='3'){
discountamount=price*0.3;}


else
{
stopProgram = true;

System.out.println("ERROR");
stopProgram = true;
}

the program doesn't stop when a wrong value is added instead it just types "ERROR" and goes and executes the next set of rules.

oh and sorry about the post
how can I edit it?

the program doesn't stop when a wrong value is added instead it just types "ERROR

You can call the System.exit(0) method to exit/stop a program immediately.
Otherwise you set a flag (boolean variable) so that your code can delay exiting the program until it has done some finishing up. Then it can test if the boolean is true and call System.exit(0).

Your code sets stopProgram = true two times??? One will do it.

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.