Question

In: Computer Science

DESIGN IN RAPTOR PROGRAMMING APP Le Chef Heureux Restaurant has 20 tables that can be reserved...

DESIGN IN RAPTOR PROGRAMMING APP Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a table already taken, reprompt the user. Continue to accept reservations until the user enters a sentinel value or all slots are filled. Then display all empty tables in each time slot.

Solutions

Expert Solution

#include<iostream>

using namespace std;

struct table{
    int time[3];
    int num;
};

void reserve(table T[], int b,int a, int n){

if (n > 4){
      cout << "Error: Number of guests exceeding four\n";
      return;
   }

   if (T[b-1].time[a] == 0){
      T[b-1].time[a] = 1;
      cout << "Table is reserved\n";
      return;
   }

   cout << "Sorry! Table is already reserved\n";
}

int main(){

    table Table[20];
    int b,g,n;
    int t;

    for (int i = 0; i<20; i++)
        for (int j=0; j<3; j++)
            Table[i].time[j] = 0;
   
    cout << "Welcome to Le Chef Heureux Reservation System\n";
    while(true){
         int found = 0;
         for (int i = 0; i<20; i++)
             for (int j=0; j<3; j++)
                if (Table[i].time[j] == 0)
                   found = 1;
          if (found == 0){
              cout << "Reservation is Full\n";
              break;
          }
      
         cout << "1.Reserve a table\n";
         cout << "2.Quit\n";
         cout << "Enter choice:";
         cin >> n;
         if (n == 1){
            while(true){
               cout << "Enter table number(1-20):";
               cin >> b;
               if (b < 1 || b > 20)
                  cout << "Error:Invalid input\n";
               else
                  break;
            }
            while(true){
               cout << "Enter time(0-5pm,1-7pm,2-9pm):";
               cin >> t;
               if (t <0 || t >2)
                  cout << "Error:Invalid input\n";
               else
                  break;
            }
            while(true){
               cout << "Enter number of guests(>=4):";
               cin >> g;
               if (g <=0 || g > 4)
                  cout << "Error:Invalid input\n";
               else
                  break;
            }
            reserve(Table,b,t,g);
            
         }
         if (n == 2)
            break;
    }
}


Related Solutions

Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m.,...
Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a table already taken, reprompt the user. Continue to accept reservations until the user...
JAVA: Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7...
JAVA: Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a JAVA program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a table already taken, re-prompt the user. Continue to accept reservations until...
Using RAPTOR Create a flowchart and create the pseudocode for the following question Le Chef Heureux...
Using RAPTOR Create a flowchart and create the pseudocode for the following question Le Chef Heureux Restaurant has 20 tables that can be reserved at 5 p.m., 7 p.m., or 9 p.m. Design a program that accepts reservations for specific tables at specific times; the user enters the number of customers, the table number, and the time. Do not allow more than four guests per table or invalid table numbers or times. If an attempt is made to reserve a...
The patio of a restaurant has three tables at which two, four, and five patrons can...
The patio of a restaurant has three tables at which two, four, and five patrons can be seated, respectively. A party of eleven is to be seated on the patio. (a) In how many ways can the party of eleven be seated at the three tables (it is not important in which seats at each table the patrons sit). (b) Three friends among the party wish to sit together. In how many ways can the party of eleven be seated...
Restaurant Pricing. Consider a restaurant that charges $10 for all, you can eat and has 20...
Restaurant Pricing. Consider a restaurant that charges $10 for all, you can eat and has 20 customers at this price. The slope of the demand curve is minus−​$0.20 per​ meal and the marginal cost of providing a meal is ​$66. ​1.) Use the line drawing tool to draw and label the demand line. ​2.) Use the line drawing tool to draw and label the marginal revenue line. ​3.) Use the line drawing tool to draw the marginal cost line. Carefully...
Gina has been head chef at a local Italian restaurant for the last 15 years. She...
Gina has been head chef at a local Italian restaurant for the last 15 years. She is from a large Italian family that loves not only cooking but also eating. Although Gina has grown up around large amounts of food and hearty appetites, she has learned to control her weight and eat moderately. However, Gina's husband, Anthony, has difficulty moderating his eating habits. They have been married for three years, and in that time Anthony has put on 20 kg,...
The owner of an exclusive restaurant has two tables but only one waiter. If the second...
The owner of an exclusive restaurant has two tables but only one waiter. If the second table is occupied, the owner waits on that table himself. Service times are exponentially distributed with mean 1 hour, and the time between arrivals is exponentially distributed with mean 1.5 hours. When the restaurant is full, people must wait outside in line. a) What percentage of the time is the owner waiting on a table? b) If the owner wants to spend at most...
Business Law Question Alina, a chef who has never owned her own restaurant, sues a builder...
Business Law Question Alina, a chef who has never owned her own restaurant, sues a builder who failed to finish building her first restaurant on time. She presents evidence of the profits made by similar restaurants that have been in business for some time. Is this good evidence of the damages she has suffered because of the delay? To what damages is she entitled?
restaurant has 5 tables available. People arrive at times of a Poisson process with rate of...
restaurant has 5 tables available. People arrive at times of a Poisson process with rate of 6 per hour. The amount of time for a person to eat has an exponential distribution with a mean of 30 minutes. People who arrive when all 5 tables are full turn around and leave without eating at the restaurant. In the long run, what fraction of time is the restaurant full?
Programming Problem Design a program in java that can perform three different arithmetic operations based on...
Programming Problem Design a program in java that can perform three different arithmetic operations based on the user’s input. The three operations are 1. Summation of integers from 1 to m 2. Factorial of a given number n (n!) 3. Finding the leftmost digit of a given integer (note: you have to use int) This program should prompt the user a menu including four options, ask the user for one option, and perform the corresponding computation. This process will repeat...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT