Question

requires python to answer

(a) A school library has 3 study rooms available for students to book during its opening hours, on a first-come-first-serve b

The student can choose not to proceed by indicating the value - 1. If so, terminate the action of booking a room. If an inval

0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 5 Select a valid avai

Available rooms 2 3 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 4

Show the relationships between the functions for the identified sub- problems using a structure chart. The structure chart sh

Enter student number of student making the booking: T2 Room is successfully booked Booked rooms 2 T2 3 T1 Available rooms 1.

(a) A school library has 3 study rooms available for students to book during its opening hours, on a first-come-first-serve basis. Assume there is no pre-booking, that is, the study rooms can be booked only on the day of usage itself. A library staff should be able to select to perform one of the following actions: Book a room o If there is no available room, the message: No study room available currently is displayed and the action of booking a room is terminated. o If there is at least one room available: The case where only one room left: ' Inform the student this is the only room number left and asks if the student wishes to proceed. If student chooses not to proceed, The case where there is more than one available roon: List the unoccupied room numbers in ascending order and allow the student to make a choice.
The student can choose not to proceed by indicating the value - 1. If so, terminate the action of booking a room. If an invalid room number is chosen, allow data re-entry for the room the number. If a valid room number is chosen or the last available room is accepted, record the oom as booked. Display the rooms that have been booked followed by the rooms that are un-booked, with appropriate headers, and with rooms sorted in ascending order of room numbers. Release a rooim Display an error message if there is currently no room booking. Otherwise, let the student specify a room number to be released. o If the specified room number is not a room number of a booked room, display an error message. o If the room number is a room number of a booked room, release the oom. Display the rooms that have been booked followed by the rooms that are un-booked, with appropriate headers, and with rooms sorted in ascending order of the room numbers. Quit the application This option allows the system to end. An example is shown here 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 There is currently no room booking 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Room 3 Select a room or -1 to quit room booking: 3 Room is successfully booked Booked rooms Available rooms 1. Book a Study Room 2. Release a Study Room
0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 5 Select a valid available room number or -1 to quit room booking List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 4 Select a valid available room number or -1 to quit room booking List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 1 Booking room is abandoned 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 2 Room is successfully booked Booked rooms 2 3 Available rooms 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 1 Only room 1 is available Proceed? y/n: y Room is successfully booked Booked rooms 1 2 3 No Available rooms 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 3 Room is successfully released Booked rooms 2 1 Available rooms 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 2 Room is successfully released Booked rooms
Available rooms 2 3 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 4 There is no booking in this study room 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 1 Room is successfully released No booked rooms Available rooms 1 2 3 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Room 3 Select a room or -1 to quit room booking: 1 Room is successfully booked Booked rooms Available rooms 3 2 1. Book a Study Room 2. Release a study Room 0. Exit Enter choice: 3 Invalid choice 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 0 Application exiting Break the problem of managing the booking and release of study rooms sub-problems by aplng top-down design to the problem. Develop and show your design by writing algorithms in pseudocode for the problem and the sub-problems. Your top-down design must show at least 3 levels of refinement and you should avoid having step duplications wherever possible as penalty applies.
Show the relationships between the functions for the identified sub- problems using a structure chart. The structure chart should show the input and output for each function. Submit the following items for part Q2(a) Your top down design in pseudocode, showing at least Your structure chart showing the functions identified for the (15 marks) (b) Develop the program to implement your design in part Q2(a). Your program should (15 marks) (c) Make a copy of your program for part Q2(b). Modify the copy to include the THREE (3) levels of refinement. sub-problems. be sufficiently documented with comments. following additional steps: (i)Booking a room Get the student number of the student making the booking. The student number must be recorded. Release a room Get the student number of the student releasing the booking. The student number must match the recorded student number for the room to be released. (10 marks) n exainple is slhown here 1. Book a Study Room 2. Release a Study Room 0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Room 3 Select a room or -1 to quit room booking: 3 Enter student number of student making the booking: T1 Room is successfully booked Booked rooms 3 T1 Available rooms 1 2 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 1 List of available rooms Room 1 Room 2 Select a room or -1 to quit room booking: 2
Enter student number of student making the booking: T2 Room is successfully booked Booked rooms 2 T2 3 T1 Available rooms 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 1 Only room 1 is available Proceed? y/n: y Enter student number of student making the booking: t3 Room is successfully booked Booked rooms 1 T3 2 T2 3 T1 No Available rooms 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 4 There is no booking in this study room 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 1 Enter student number: T1 Inccorect student number Booked rooms 1 T3 2 T2 3 T1 No Available rooms 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 2 Enter the room number to release: 1 Enter student number: T3 Room is successfully released Booked rooms 2 T2 3 T1 Available rooms 1. Book a study Room 2. Release a Study Room 0. Exit Enter choice: 0 Application exiting
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Please find the required solution for a (Please post the rest of the them as separate question)
# define arrays for available rooms, booked rooms (initially all rooms are available)
available_rooms = [1, 2, 3]
booked_rooms = []

# define method for print menu
def print_menu():
   print("1. Book a Study Room")
   print("2. Release a Study Room")
   print("0. Exit")

# print available rooms with label "Room"
def print_available_rooms_list():
   if  len(available_rooms) == 0:
      print('No Available Rooms')
      return
   print("Available Rooms")
   for i in available_rooms:
      print('Room ', i, end='\t')
   print()

# print available room numbers
def print_available_rooms():
        if  len(available_rooms) == 0:
                print('No Available Rooms')
                return
        print("Available Rooms")
        for i in available_rooms:
                print(i, end='\t')
        print()

# print booked rooms with label "Room"
def print_booked_rooms():
   if len(booked_rooms) == 0:
      print('No Booked Rooms')
      return
   print("Booked Rooms")
   for i in booked_rooms:
      print(i, end="\t")
   print()

# print booked room numbers
def print_booked_rooms_list():
        if len(booked_rooms) == 0:
                print('No Booked Rooms')
                return
        print("Booked Rooms")
        for i in booked_rooms:
                print('Room ',i, end="\t")
        print()

# method to book room on required input
def book_room():
   if len(available_rooms) == 0 :
      print('No study room available currently')
      return
   elif len(available_rooms) == 1:
      print('Only room ', available_rooms[0], ' is available')
      inp = input('Proceed? y/n:')
      if inp == 'y':
         process_book_room(available_rooms[0])
   else:
      print_available_rooms_list()
      inp = int(input('Select a room or -1 to quit room booking:'))
      if inp == -1:
         print("Booking room is abondoned.")
         return
      elif inp not in available_rooms:
         print("select valid available room number or -1 to quit room booking")
         book_room()
         return
      else:
         process_book_room(inp)

   print("Room is successfull Booked")
   print_booked_rooms()
   print_available_rooms()

def process_book_room(room_number):
   available_rooms.remove(room_number)
   booked_rooms.append(room_number)

def process_release_room(room_number):
        available_rooms.append(room_number)
        booked_rooms.remove(room_number)

# method for release room
def release_room():
   if len(booked_rooms) == 0:
      print('There is currently no room booking')
   else:
      print_booked_rooms_list()
      inp = int(input("Enter the room number to release:"))
      if inp not in booked_rooms:
         print('There is no booking in this study room')
      else:
         process_release_room(inp)
         print('Room is successfully released')
      print_booked_rooms()
      print_available_rooms()

# main method to simulate the booking
def main():
   print_menu()
   opt = int(input("enter choice:"))
   if opt == 1:
      book_room()
   elif opt == 2:
      release_room()
   elif opt == 0:
      print("Application Exiting.")
      return
   else:
      print('Invalid choice.')
   main()
main()

sample output:

1. Book a Study Room 2. Release a Study Roorm 0. Exit enter choice:1 Available Rooms Room 1 Room 2 Room 3 Select a room or -1

1. Book a Study Room 2. Release a Study Roorm 0. Exit enter choice:2 BookedRooms Room 1 Room 3 Enter the room number to relea

Add a comment
Know the answer?
Add Answer to:
requires python to answer (a) A school library has 3 study rooms available for students to book during its opening hours, on a first-come-first-serve basis. Assume there is no pre-booking, that...
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
  • Write a program in Java, Python and Lisp When the program first launches, there is a...

    Write a program in Java, Python and Lisp When the program first launches, there is a menu which allows the user to select one of the following five options: 1.) Add a guest 2.) Add a room 3.) Add a booking 4.) View bookings 5.) Quit The functionality of these options is as follows: 1.) When users add a guest they provide a name which is stored in some manner of array or list. Guests are assigned a unique ID...

  • making a file You are tasked with creating a text-based program for storing data on Hotel...

    making a file You are tasked with creating a text-based program for storing data on Hotel Room Bookings - however, as this is a comparative languages course, you will be creating the same application in the following three programming languages: • Java, • Python, and • Lisp As you implement the application in each language you should keep notes on: - The features of the languages used, - Which features you found useful, and - Any issues or complications which...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

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