Please Help !! :((

Recommended Answers

All 13 Replies

should include: reservation of tables and rooms
Customer billing system and restaurant menu

What problems are you having with your code? Post your questions and the code.

What've you got done so far? Is this a web-based or a client-side application? How're you handling the data (filesystems, databases etc.)? It's difficult to help you with so little information.

commented: thanks and NOW please HELp +0
import java.io.*;
class Rooms_n_Tables
 {


       int index=6;
      String resRom[] = new String[index];
      int roomNum;
      String A="Available";
      String R="Reserved";
    int choose;
    public  void main(String[] args)throws IOException 
    {
            roomDis();
            menu(); 
    }   

    public void choose() throws IOException
    {
        BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter [1] for Reservation of Rooms \n Enter [2] for Reservation of Tables \n Enter [3]to Exit \n");
        int choice = Integer.parseInt(x.readLine());
         if (choice==1)
           {
               roomDis();
            menu();

       }
       else if (choice==2) 
        {

            roomDisr();
             menur();

           }
           else if(choice==3)
           System.exit(0);
           else
           {
               System.out.print("Invalid Input \n");
               choose();
           }

}
void roomDis()throws IOException
    {   
        BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("[1]-AC \n [2] - Non AC rooms"); 
        int ac = Integer.parseInt(a.readLine());
        if (ac==1)
        {space();
        sop("ROOM #.     STATUS\n\n");
        roomNum=1;
        for(int i=1;i<index;i++) {

            resRom[i]=A;
            System.out.println("   " +roomNum + "\t    " +resRom[i]);
            roomNum++;
        }

    }
    else if (ac==2)
    {
        space();
        sop("ROOM #.     STATUS(Non Ac Rooms)\n\n");
        roomNum=1;
        for(int i=1;i<index;i++) 
        {

            resRom[i]=A;
            System.out.println("   " +roomNum + "\t    " +resRom[i]);
            roomNum++;
}
}
}


 void roomDisOrg()
{

        space();
        System.out.print("ROOM #.     STATUS\n\n");
        roomNum=1;
        for(int i=1;i<index;i++) 
        {

            System.out.println("   " +roomNum + "\t    " +resRom[i]);
            roomNum++;
        }

    }

     void menu()throws IOException 
     {

    try {

        BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
        sop("\n\nMenu \n [1] - Reserve \n [2] - Cancel Reservation \n [3] - Exit \n [4] Menu Again");   
        sop("\n\n\nEnter Menu: ");

int menu = Integer.parseInt(k.readLine());

        switch(menu) {
            case 1:

                    System.out.print("Enter the room #: ");
                    int rNo = Integer.parseInt(k.readLine());

                        if(resRom[rNo]==A) {

                            resRom[rNo]=R;
                            roomDisOrg();
                            System.out.println("\n\nRoom number " + rNo + " reserved!");
                            menu();

                        }else 
                        {
                           space();
                           roomDisOrg();
                           System.out.println("\n\nRoom number " + rNo + " already reserved!");
                           menu();
                        }   



                break;
            case 2:


                    System.out.print("Enter the room #: ");
                    int rNo1 = Integer.parseInt(k.readLine());


                    System.out.print("\nCancel this room?[1]-Yes/[2]-No: ");
                    int ask = Integer.parseInt(k.readLine());

                        if(ask==1) {

                            if(resRom[rNo1]==R) {

                               space();
                               resRom[rNo1] = A;
                               roomDisOrg();
                               System.out.println("\n\nRoom number " + rNo1 + " is now " + A);
                               menu();

                            }else {

                               space();
                               roomDisOrg();
                               System.out.println("\n\nRoom number " + rNo1 + " is already " + A);
                               menu();

                            }

                        }else if(ask==2) {

                            space();
                            roomDisOrg();
                            menu();

                        }else {

                            sop("Invalid Input...\n");  

                        }       

                break;
            case 3:

                System.exit(0);
                break;

            case 4 :
            choose();
            break;

                default:

                space();
                roomDisOrg();
                System.out.println("\n\nInvalid menu!");
                menu();
                break;
        }

        }catch(NumberFormatException er) {

                space();
                roomDisOrg();
                System.out.println("\n\nInvalid menu!");
                menu();

        }

    }

     void sop(String str) {
        System.out.print(str);
    }

     void space() {
        sop("\n\n\n\n\n\n\n\n\n\n\n\n");
    }

 void roomDisr() {


 System.out.print("TABLE #.     STATUS\n\n");
        roomNum=1;
        for(int i=1;i<index;i++) {

            resRom[i]=A;
            System.out.println("   " +roomNum + "\t    " +resRom[i]);
            roomNum++;
        }
}
void menur()throws IOException {

    try {

        BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("\n\nMenu \n [1] - Reserve \n [2] - Cancel Reservation \n [3] - Exit");    
        System.out.print("\n\n\nEnter Menu: ");

int menu = Integer.parseInt(k.readLine());

        switch(menu) {
            case 1:

                    System.out.print("Enter the Table #: ");
                    int rNo = Integer.parseInt(k.readLine());

                        if(resRom[rNo]==A) {

                            resRom[rNo]=R;
                            roomDisOrgr();
                            System.out.println("\n\nTable number " + rNo + " reserved!");
                            menur();

                        }else {
                           spacer();
                           roomDisOrgr();
                           System.out.println("\n\ntable number " + rNo + " already reserved!");
                           menur();
                        }   



                break;
            case 2:


                    System.out.print("Enter the room #: ");
                    int rNo1 = Integer.parseInt(k.readLine());


                    System.out.print("\nCancel this room?[1]-Yes/[2]-No: ");
                    int ask = Integer.parseInt(k.readLine());

                        if(ask==1) {

                            if(resRom[rNo1]==R) {

                               spacer();
                               resRom[rNo1] = A;
                               roomDisOrgr();
                               System.out.println("\n\n TAB number " + rNo1 + " is now " + A);
                               menur();

                            }else {

                               spacer();
                               roomDisOrgr();
                               System.out.println("\n\nRoom number " + rNo1 + " is already " + A);
                               menur();

                            }

                        }else if(ask==2) {

                            spacer();
                            roomDisOrgr();
                            menur();

                        }else {

                            System.out.print("Invalid Input...\n"); 

                        }       

                break;
            case 3:

                System.exit(0);
                break;

            default:

                spacer();
                roomDisOrgr();
                System.out.println("\n\nInvalid menu!");
                menur();
                break;
        }

        }catch(NumberFormatException er) {

                spacer();
                roomDisOrgr();
                System.out.println("\n\nInvalid menu!");
                menur();

        }
}
void roomDisOrgr() {

        spacer();
        System.out.print("TABLE #.     STATUS\n\n");
        roomNum=1;
        for(int i=1;i<index;i++) {

            System.out.println("   " +roomNum + "\t    " +resRom[i]);
            roomNum++;
        }

    }

     void spacer() {
        System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n");
    }
}

i just want you to add a restaurant menu and a billing system
that all but PLEASE HELP I HAVE TO SUBMIT IT IN ABT 2-3 DAYS

What design ideas do you have for adding the new features? What problems are you having coding them?

this is the updated one.....the problem is :
i cant get the billing thing right
and i always get the total as 0 PLZ HELP!!!
import java.io.*;
public class RestaurantSystem
{
BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
int roti,veggie,pepper,rno=1,price,dish,choice,rtot=70,vtot,ptot,gtot,ntot,patot;

    public void order()throws IOException
    {
        System.out.println("....................Welcome to Our Restaurant....................\n");
        System.out.println("What would you like to have ?\n Enter [1] for Vegetarian and \n[2] for Non-Vegetarian");
         choice =Integer.parseInt(k.readLine());
       menu();

        BufferedReader k = new BufferedReader(new InputStreamReader(System.in));

        }
        public void menu()throws IOException
        {
         if(choice == 1)
        {

            System.out.println("..........................MENU..........................");
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("Roti[1]    \t its served hot  \t   Rs35");
             System.out.println("veggie[2]  \t its served hot  \t      Rs95");
             System.out.println("5 Pepper[3]\t its served hot  \t         Rs300");
             System.out.println("Please give your order \n Enter the char in the brackets\n and [5] to Quit \n and [4] if order is over");
             dish =Integer.parseInt(k.readLine());


             if(dish==1)
            {

              System.out.println("You have chose to order a roti");
               System.out.println("Enter the Quantity you want");
             int rno=Integer.parseInt(k.readLine());
             int rtot=rno*35;
             menu();
            }
            else if (dish==2)
             {
              System.out.println("You have chose to order a Veggie"+rtot);
              System.out.println("Enter the Quantity you want");


             int  vtot=vno*95;
             menu();
            }

             else if (dish==3)
            {
               System.out.println("You have chose to order a 5 Pepper");
              System.out.println("Enter the Quantity you want");
             int pno=Integer.parseInt(k.readLine());
             int ptot=pno*300;
             menu();
            }

             else if(dish==4)
             {
                 int total=rtot+vtot+ptot;
                  System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("Roti[1]    \t its served hot  \t   "+rtot);
             System.out.println("veggie[2]  \t its served hot  \t   " +vtot);
             System.out.println("5 Pepper[3]\t its served hot  \t   " +ptot);
               System.out.println("Total bill ="+total) ;

            }

             else if (dish==5)
              System.exit(0);



            }

            else if (choice==2)
               {
            System.out.println("..........................MENU..........................");
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("ghat[1]    \t its served hot  \t   Rs2000");
             System.out.println("nonvvv[2]  \t its served hot  \t      Rs6000");
             System.out.println("5 Papad [3]\t its served hot  \t         Rs12000");
             System.out.println("Please give your order \n Enter the char in the brackets\n and [4] to Quit \n and [5] if order is over");
             dish =Integer.parseInt(k.readLine());

               if(dish==1)
            {
              System.out.println("You have chose to order a ghat");
               System.out.println("Enter the Quantity you want");
             int gno=Integer.parseInt(k.readLine());
             int gtot=gno*2000;
               menu();
            }


             if(dish==2)
            {
              System.out.println("You have chose to order a Veggie");
              System.out.println("Enter the Quantity you want");
              int nno=Integer.parseInt(k.readLine());
             int  ntot=nno*6000;
             menu();
            }

               if(dish==3)
            {
               System.out.println("You have chose to order a 5 Pepper");
              System.out.println("Enter the Quantity you want");
             int pano=Integer.parseInt(k.readLine());
             int patot=pano*12000;
             menu();
            }

                  if(dish==4)
            {
                int total = gtot+ntot+patot;
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("ghat[1]    \t its served hot  \t  "+gtot);
             System.out.println("nonvvv[2]  \t its served hot  \t   "+ntot);
             System.out.println("5 Papad [3]\t its served hot  \t   "+patot);
               System.out.println("Total bill =" + total);

            }

                if(dish==5)

              System.exit(0);



        }
    }
}

i always get the total as 0

Add some println statements to the code to show the values of the variables used to compute the total. Print out the values of all the variables and the results of all of the computations that are done to compute the total. The output will show you where the problem is in the code. If you have any questions about the print out you get, post the print out and your questions about it and the code that generates it.

THIS IS THE OUTPUT:
YOU CAN SEE I GET THE PRICE OF THE "ROTI" IN THE FINAL BILL AS ZERO

...................Welcome to Our Restaurant....................

What would you like to have ?
 Enter [1] for Vegetarian and 
[2] for Non-Vegetarian
1
..........................MENU..........................
     Name        Description              Price
Roti[1]      its served hot        Rs35
veggie[2]    its served hot           Rs95
5 Pepper[3]  its served hot              Rs300
Please give your order 
 Enter the char in the brackets
 and [5] to Quit 
 and [4] if order is over
1
You have chose to order a roti
Enter the Quantity you want
24
840
..........................MENU..........................
     Name        Description              Price
Roti[1]      its served hot        Rs35
veggie[2]    its served hot           Rs95
5 Pepper[3]  its served hot              Rs300
Please give your order 
 Enter the char in the brackets
 and [5] to Quit 
 and [4] if order is over
4
     Name        Description              Price
Roti[1]      its served hot        0
veggie[2]    its served hot        0
5 Pepper[3]  its served hot        0
Total bill =0
THIS IS THE CODE:
import java.io.*;
public class RestaurantSystem
{
BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
int roti,veggie,pepper,rno=1,price,dish,choice,rtot,vtot,ptot,gtot,ntot,patot;

    public void order()throws IOException
    {
        System.out.println("....................Welcome to Our Restaurant....................\n");
        System.out.println("What would you like to have ?\n Enter [1] for Vegetarian and \n[2] for Non-Vegetarian");
         choice =Integer.parseInt(k.readLine());
       menu();

        BufferedReader k = new BufferedReader(new InputStreamReader(System.in));

        }
        public void menu()throws IOException
        {
         if(choice == 1)
        {

            System.out.println("..........................MENU..........................");
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("Roti[1]    \t its served hot  \t   Rs35");
             System.out.println("veggie[2]  \t its served hot  \t      Rs95");
             System.out.println("5 Pepper[3]\t its served hot  \t         Rs300");
             System.out.println("Please give your order \n Enter the char in the brackets\n and [5] to Quit \n and [4] if order is over");
             dish =Integer.parseInt(k.readLine());


             if(dish==1)
            {

              System.out.println("You have chose to order a roti");
               System.out.println("Enter the Quantity you want");
             int rno=Integer.parseInt(k.readLine());
             int rtot=rno*35;
              System.out.println( rtot);
              menu();
            }
            else if (dish==2)
             {
              System.out.println("You have chose to order a Veggie"+rtot);
              System.out.println("Enter the Quantity you want");

             int vno=Integer.parseInt(k.readLine()); 
             int  vtot=vno*95;
           System.out.println( vtot);
           menu();
            }

             else if (dish==3)
            {
               System.out.println("You have chose to order a 5 Pepper");
              System.out.println("Enter the Quantity you want");
             int pno=Integer.parseInt(k.readLine());
             int ptot=pno*300;
             System.out.println( ptot);
             menu();
            }

             else if (dish==5)
              System.exit(0);





            else if (dish==4)

             {  ;
             int total =rtot+vtot+ptot;
            System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("Roti[1]    \t its served hot  \t   "+rtot*35);
             System.out.println("veggie[2]  \t its served hot  \t   " +vtot*95);
             System.out.println("5 Pepper[3]\t its served hot  \t   " +ptot);
               System.out.println("Total bill =" + total);  




            }


        }

           else if (choice==2)
               {
            System.out.println("..........................MENU..........................");
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("ghat[1]    \t its served hot  \t   Rs2000");
             System.out.println("nonvvv[2]  \t its served hot  \t      Rs6000");
             System.out.println("5 Papad [3]\t its served hot  \t         Rs12000");
             System.out.println("Please give your order \n Enter the char in the brackets\n and [4] to Quit \n and [5] if order is over");
             dish =Integer.parseInt(k.readLine());

               if(dish==1)
            {
              System.out.println("You have chose to order a ghat");
               System.out.println("Enter the Quantity you want");
             int gno=Integer.parseInt(k.readLine());
             int gtot=gno*2000;
              System.out.println( gtot);  
             menu();

            }


             if(dish==2)
            {
              System.out.println("You have chose to order a Veggie");
              System.out.println("Enter the Quantity you want");
              int nno=Integer.parseInt(k.readLine());
             int  ntot=nno*6000;
             System.out.println( ntot);
             menu();
            }

               if(dish==3)
            {
               System.out.println("You have chose to order a 5 Pepper");
              System.out.println("Enter the Quantity you want");
             int pano=Integer.parseInt(k.readLine());
             int patot=pano*12000;
              System.out.println( patot);
             menu();
            }

                  if(dish==5)
            {
                int total = gtot+ntot+patot;
             System.out.println("\t Name    \t Description     \t      Price");
             System.out.println("ghat[1]    \t its served hot  \t  "+gtot);
             System.out.println("nonvvv[2]  \t its served hot  \t   "+ntot);
             System.out.println("5 Papad [3]\t its served hot  \t   "+patot);
               System.out.println("Total bill =" + total);


            }

                if(dish==4)

              System.exit(0);



        }


}
}

Add some println statements to the code to show the values of the variables used to compute the total. Print out the values of all the variables and the results of all of the computations that are done to compute the total. The output will show you where the problem is in the code. If you have any questions about the print out you get, post the print out and your questions about it and the code that generates it.
The print out of the numbers does not say what variable is being printed.The printlns in the code do NOT label the values that are printed so you will not know what a printed number is. The printlns should include a String with the name of the variable that is being printed.

Check that you have only one definitiion for the variables.

commented: i dint understand what you mean ...Please can you edit that part of my code and paste it +0
can you post my code with the required changes please?
because i cant understand what you mean :(

I haven't read your entire code, but I think he means that you are overwriting (hiding) some of your class variables in smaller scopes, and updating those local variables. but since you re-declare them, the value of your class variable isn't updated when you change the local one, so when you eventually ask the value of the class variable, you'll end up with the default value.

Yes, that's exactly what it looks like. On line 6 you declare rtot,vtot,ptot,gtot,ntot,patot, but then on lines 38, 49, etc you declare new local variables with the same names.

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.