Question

Objectives This is one of three major programming projects this semester. You should NOT collaborate on this project. While y

Spring 2020 - CS1083 - Section Dox - Project 2 - written by YOURNAME Restaurant Front Desk Welcome to XYZ restaurant ----- MEDetails The Console You will need to use scanner to obtain input from the keyboard. You should declare a class constant of ty

• seats: Used to store the number of seats per table. In this program it is assumed that it will be filled with the values 2,

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

import java.util.*;

class RestaurantFrontDesk{

void newCustomer(int seats[],boolean occupied[],String names[],int seat,String name) //Checks if seat is available for a new customer
{
int pos=-1;
for(int i=0;i<5;i++)
{
if(seat<=seats[i] && occupied[i]==false) //Finds new seat if available
{
pos=i;
break;
}
}
if(pos!=-1){
occupied[pos]=true;
names[pos]=name;
System.out.println("Welcome "+names[pos]+" your table is the number"+(pos+1));
}
else
System.out.println("We are Sorry, No table available");
}

void status(String names[],boolean occupied[],int seats[])

//Prints the status of the Restaurant seating condition
{
for(int i=0;i<5;i++)
{
if(occupied[i]==true)
System.out.println("Table: "+(i+1)+" Seats: "+seats[i]+" Name: "+names[i]);
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int ch;
int seats[]={2,2,4,5,8};
boolean occupied[]={false,false,false,false,false};
String names[]=new String[5];
System.out.println("Spring 2020 - CS1083 _ Section ))X - Project 2 - Written By YOURNAME \n Restaurant Front Desk");
System.out.println("----------------------");
System.out.println("Welcome to XYZ Restaurant");
RestaurantFrontDesk ob=new RestaurantFrontDesk();
while(true)
{
System.out.println("------MENU------ ");
System.out.println("0: Exit ");
System.out.println("1: New Customer ");
System.out.println("2: Empty Table ");
System.out.println("3: Print Status ");
System.out.print("What is your choice? ");
ch=sc.nextInt();

if(ch==0)
{
System.out.println("Thank You and Good Bye");
break;
}
else if(ch==1)
{
System.out.print("Customer's Name? ");
sc.nextLine();
String name=sc.nextLine();
System.out.print("For how many People? ");
int seat=sc.nextInt();
if(seat<9)
ob.newCustomer(seats,occupied,names,seat,name);
else
System.out.println("We are sorry, No table Available");
}
else if(ch==2)
{
System.out.print("What table was made available? ");
int table=sc.nextInt();
if(table>5)
System.out.println("Table no. out of range");
else
{ //Empties a table if it is occupied
  
if(occupied[table-1]==false)
System.out.println("Table"+table+" is not occupied");
else
{
System.out.println("We hope to have you back soon, "+names[table-1]);
occupied[table-1]=false;
names[table-1]="";
}
}
}
else if(ch==3)
{
ob.status(names,occupied,seats);
}
else
System.out.println("Wrong Option Selected. Please Try Again");
}
}
}

Add a comment
Know the answer?
Add Answer to:
Objectives This is one of three major programming projects this semester. You should NOT collaborate on...
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
  • Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating...

    Program Description: A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 1 2 3 21 22 23 24 25 Implement a well-structured Java program to enable a user to make and cancel seat reservations for the bus. The program uses Array to store the reservation information: 0...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is...

    A bus has 28 seats, arranged in 7 rows and 4 columns: This seating arrangement is mapped, row-wise, to a 1D-array of size 28: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Implement a well-structured C program to enable a user to make and cancel seat reservations for the bus. The program uses a text-file seats.txt to store the reservation...

  • In this project, you will use functions and dictionaries to track basketball players and their respective...

    In this project, you will use functions and dictionaries to track basketball players and their respective points, then display statistics of points made. You will need three functions as follows: def freeThrowMade(playerDictionary, playerName) - this function will add 1 point to the player's total score def twoPointMade(playerDictionary, playerName) - this function will add 2 points to the player's total score def threePointMade(playerDictionary, playerName) - this function will add 3 points to the player's total score Each of these functions has...

  • Phase one implementation: 1-The menu of selections implemented in main function. 2- Each choice should be...

    Phase one implementation: 1-The menu of selections implemented in main function. 2- Each choice should be implemented in the main function. 3- The data is saved permanently in a file. Problem Description: Assume one of the companies in Qatar who is renting flats for people asks you to develop a small system to help them track who paid the rent fees, and who did not for the coming month. The data in this system includes: ID number of the person...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • java Part 1 Create a NetBeans project that asks for a file name. The file should...

    java Part 1 Create a NetBeans project that asks for a file name. The file should contain an unknown quantity of double numeric values with each number on its own line. There should be no empty lines. Open the file and read the numbers. Print the sum, average, and the count of the numbers. Be sure to label the outputs very clearly. Read the file values as Strings and use Double.parseDouble() to convert them. Part 2 Create a NetBeans project...

  • (Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system

    (Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system. You'll write a program to assign seats on each flight of the airline's only plane (capacity: 10 scats).Your program should display the following menu of alternatives:Please type 1 for "first class"please type 2 for "economy"If the person types 1 , then your program should assign a seat in the first class section (seats...

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