Question

Part II: Let Me Inn (20 points) You are the manager of the Let Me Inn....

Part II: Let Me Inn (20 points)
You are the manager of the Let Me Inn. A travel agent has sent you a list of reservations that can be accommodated
by the hotel. Your primary job is to send him back the total cost of the reservations. To make sure your hotel runs
properly, you also will keep track of how much money you have made from each type of room (Normal, Double,
King, Suite).
Complete the function hotel manager which takes arguments in the following order:
1. room prices: A dictionary that maps a type of room (a string) to the price of the room (an integer).
2. room counts: A dictionary that maps a type of room (a string) to the number of available rooms of that
type (an integer).
3. reservations: A list of sub-lists wherein the first element of a sub-list contains the type of room being
reserved, and the second element is the desired count of rooms of that type. For example, the sub-list
[’King’, 3] would indicate that 3 King rooms are desired.
The function iterates over the reservations list, extracting the room type and room count of each reservation.
Room types can appear multiple times in the list. Then, the function looks up the price of the desired room
using the room prices dictionary and determines what it would cost to reserve the desired number of rooms.
You may assume that the room type in the reservation always has a corresponding price in room prices and a
corresponding count in room counts.
If there are enough available rooms to accept the reservation, the function (1) updates the total income generated
by the reservation, (2) updates room counts to reflect that fewer rooms are now available, and (3) updates a
dictionary that tracks how much income was generated by each type of room. As an example, suppose that a King
room costs $200 per night and 3 have such rooms been successfully reserved. Suppose also that we have created a
dictionary called room incomes to store the income generated by each room type. In this example, the function
would add 600 both to room incomes[’King’] and to the total income generated. It would also subtract 3
from room counts[’King’].
If a certain reservation in reservations list cannot be accommodated due to a shortage of rooms, the function
skips over that reservation and moves on to the next one in the list.
At the end, the function returns two values in a tuple: the total income generated by the accepted reservations,
followed by the updated room incomes dictionary.


Examples:
Function Call Return Values
hotel manager({’Normal’: 70, ’Double’: 105,
’King’: 195, ’Suite’: 249}, {’Normal’: 13,
’Double’: 9, ’King’: 5, ’Suite’: 3}, [[’Suite’,
1], [’King’, 3], [’Double’, 6], [’King’, 5],
[’King’, 3], [’King’, 5]])
(1464, {’Suite’:
249, ’King’: 585,
’Double’: 630})
hotel manager({’Normal’: 79, ’Double’: 101,
’King’: 190, ’Suite’: 270}, {’Normal’: 12,
’Double’: 7, ’King’: 7, ’Suite’: 3}, [[’King’,
4], [’Double’, 7], [’Suite’, 2]])
(2007, {’King’: 760,
’Double’: 707,
’Suite’: 540})
hotel manager({’Normal’: 60, ’Double’: 128,
’King’: 178, ’Suite’: 226}, {’Normal’: 11,
’Double’: 8, ’King’: 5, ’Suite’: 4}, [[’Suite’,
1], [’King’, 5], [’Suite’, 2], [’Normal’, 9]])
(2108, {’Suite’:
678, ’King’: 890,
’Normal’: 540})
hotel manager({’Normal’: 78, ’Double’: 106,
’King’: 193, ’Suite’: 239}, {’Normal’: 12,
’Double’: 10, ’King’: 6, ’Suite’: 3},
[[’Suite’, 3], [’Double’, 5], [’King’, 3],
[’Suite’, 2], [’King’, 4], [’Double’, 5],
[’Double’, 7]])
(2356, {’Suite’: 717,
’Double’: 1060,
’King’: 579})
hotel manager({’Normal’: 97, ’Double’: 144,
’King’: 185, ’Suite’: 242}, {’Normal’:
11, ’Double’: 7, ’King’: 7, ’Suite’: 4},
[[’Normal’, 10], [’King’, 3], [’King’, 4],
[’King’, 4]])
(2265, {’Normal’:
970, ’King’: 1295})
hotel manager({’Normal’: 73, ’Double’: 145,
’King’: 160, ’Suite’: 295}, {’Normal’: 11,
’Double’: 8, ’King’: 7, ’Suite’: 3}, [[’King’,
5], [’Double’, 5], [’Suite’, 1], [’Double’, 6],
[’Double’, 7], [’Suite’, 3]])
(1820, {’King’: 800,
’Double’: 725,
’Suite’: 295})
hotel manager({’Normal’: 73, ’Double’: 145,
’King’: 162, ’Suite’: 215}, {’Normal’:
11, ’Double’: 7, ’King’: 6, ’Suite’: 4},
[[’Normal’, 11], [’Normal’, 11], [’Suite’, 1],
[’Suite’, 1], [’Double’, 7], [’Double’, 5],
[’Suite’, 0]])
(2248, {’Normal’:
803, ’Suite’: 430,
’Double’: 1015})
hotel manager({’Normal’: 62, ’Double’: 100,
’King’: 164, ’Suite’: 252}, {’Normal’: 0,
’Double’: 0, ’King’: 0, ’Suite’: 0}, [])
(0, {})
hotel manager({’Normal’: 60, ’Double’: 124,
’King’: 155, ’Suite’: 296}, {’Normal’: 12,
’Double’: 8, ’King’: 5, ’Suite’: 4}, [])
(0, {})
hotel manager({’Normal’: 60, ’Double’: 107,
’King’: 155, ’Suite’: 299}, {’Normal’: 0,
’Double’: 0, ’King’: 0, ’Suite’: 0}, [])
(0, {})

In python thank you

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def hotel_manager(room_prices, room_counts, reservation_list):

    # This dictionary store earned money from each room type
    # Key is room type and value is income
    income_list = {}

    # Total money earned
    total_income = 0

    # For each sub list in reservation list
    for sublist in reservation_list:

        room_type = sublist[0]      # sublist[0] contains type of room to be reserved
        num_rooms = sublist[1]      # sublist[1] contains cost of room to be reserved

        # Check if number of room type to be reserved are available or not
        # If yes, calculate the total cost incurred
        # Else, skip reservation
        if room_counts[room_type] >= num_rooms:

            # cost =  number of rooms to be reserved * price of that room
            cost = (num_rooms * room_prices[room_type])

            # If type of room is already present in dictionary
            # Update dictionary by updating income generated for current room_type
            # Else, add new room_type in dictionary
            if room_type in income_list.keys():
                income_list[room_type] = income_list[room_type] + cost
            else:
                income_list[room_type] = cost

            # Increment total income by adding cost to it
            total_income += cost

            # Update count in room_counts dictionary
            room_counts[room_type] -= num_rooms

    # Return total_income and income_list
    return total_income, income_list


if __name__ == '__main__':
    income = hotel_manager({'Normal': 70, 'Double': 105, 'King': 195, 'Suite': 249},
                           {'Normal': 13, 'Double': 9, 'King': 5, 'Suite': 3},
                           [['Suite', 1], ['King', 3], ['Double', 6], ['King', 5], ['King', 3], ['King', 5]])
    print(income)

    income = hotel_manager({'Normal': 79, 'Double': 101, 'King': 190, 'Suite': 270},
                           {'Normal': 12, 'Double': 7, 'King': 7, 'Suite': 3},
                           [['King', 4], ['Double', 7], ['Suite', 2]])
    print(income)

    income = hotel_manager({'Normal': 60, 'Double': 128, 'King': 178, 'Suite': 226},
                           {'Normal': 11, 'Double': 8, 'King': 5, 'Suite': 4},
                           [['Suite', 1], ['King', 5], ['Suite', 2], ['Normal', 9]])
    print(income)

    income = hotel_manager({'Normal': 78, 'Double': 106, 'King': 193, 'Suite': 239},
                           {'Normal': 12, 'Double': 10, 'King': 6, 'Suite': 3},
                           [['Suite', 3], ['Double', 5], ['King', 3],['Suite', 2], ['King', 4], ['Double', 5],['Double', 7]])
    print(income)

    income = hotel_manager({'Normal': 97, 'Double': 144, 'King': 185, 'Suite': 242},
                           {'Normal': 11, 'Double': 7, 'King': 7, 'Suite': 4},
                           [['Normal', 10], ['King', 3], ['King', 4],['King', 4]])
    print(income)

    income = hotel_manager({'Normal': 73, 'Double': 145, 'King': 160, 'Suite': 295},
                           {'Normal': 11, 'Double': 8, 'King': 7, 'Suite': 3},
                           [['King',5], ['Double', 5], ['Suite', 1], ['Double', 6],['Double', 7], ['Suite', 3]])
    print(income)

    income = hotel_manager({'Normal': 73, 'Double': 145, 'King': 162, 'Suite': 215},
                           {'Normal': 11, 'Double': 7, 'King': 6, 'Suite': 4},
                           [['Normal', 11], ['Normal', 11], ['Suite', 1],['Suite', 1], ['Double', 7], ['Double', 5],
                            ['Suite', 0]])
    print(income)

    income = hotel_manager({'Normal': 62, 'Double': 100, 'King': 164, 'Suite': 252},
                           {'Normal': 0, 'Double': 0, 'King': 0, 'Suite': 0},
                           [])
    print(income)

    income = hotel_manager({'Normal': 60, 'Double': 124, 'King': 155, 'Suite': 296},
                           {'Normal': 12, 'Double': 8, 'King': 5, 'Suite': 4},
                           [])
    print(income)

    income = hotel_manager({'Normal': 60, 'Double': 107, 'King': 155, 'Suite': 299},
                           {'Normal': 0, 'Double': 0, 'King': 0, 'Suite': 0},
                           [])
    print(income)

SCREENSHOT

HotelManagement.py x def hotel manager (room prices, room counts, reservation list): # This dictionary store earned money fro

total income cost 34 35 36 37 38 39 40 41 42if e 43 # Update count in room counts dictionary room counts [room type] -= num r

65 [Normal, 10, [King, 3, King, 4],King,4]]) print (income) 67 68 69 70 71 72 73 74 75 76 income hotel_manager (Norma

OUTPUT

otelManagement E:\Practice \ Python,ven叭Scripts\python.exe E: /Practice/Pyth (1464, (Suite: 249, King: 585, Double 630])

Add a comment
Know the answer?
Add Answer to:
Part II: Let Me Inn (20 points) You are the manager of the Let Me Inn....
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
  • C ++ Project Description The BlueMont chain hotels have 4 different types of room: Single room:...

    C ++ Project Description The BlueMont chain hotels have 4 different types of room: Single room: $60/night Double room: $75/night King room:   $100/night Suite room: $150/night The size of the hotel chains in different locations may be different in terms of the number of floors and the type and the number of rooms on each floor. You are required to write a program that calculates the occupancy rate and the total hotel income for one night and displays this information as...

  • need help MYSQL # 9 to 17 please Perform the following (each 3 Points): 1. List...

    need help MYSQL # 9 to 17 please Perform the following (each 3 Points): 1. List full details of all hotels. 2. List full details of all hotels in London 3. List the names and addresses of all guests in London, alphabetically ordered by name. 4. List all double or family rooms with a price below $40 per night, in ascending order of price. 5. List the bookings for which no dateTo has been specified. 6. How many hotels are...

  • The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName,...

    The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName, city) Room (roomNo, hotelNo, type, price) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Guest (guestNo, guestName, guestAddress) where Hotel contains hotel details and hotelNo is the primary key; Room contains room details for each hotel and (roomNo, hoteINo) forms the primary key; Booking contains details of bookings and (hoteINo, guestNo, dateFrom) forms the primary key; Guest contains guest details and guestNo is the primary key....

  • While vacationing in England, you decide to take an impromptu trip outside of London to see some ...

    While vacationing in England, you decide to take an impromptu trip outside of London to see some of the country. You phone several hotels in the area but are told that all rooms are reserved. You and your friends decide to go anyway, vowing that if worse comes to worse you will all sleep in the car. Having driven the 100 miles from London, you stop at the first hotel you see, Ye Olde Ox and Bow, and are surprised...

  • the first question java code eclipse app the second question is java fx gui caculator please...

    the first question java code eclipse app the second question is java fx gui caculator please fast 1. Create project called "YourFirstName_QUID'. Eg. Aliomar_202002345 2. Create two package Q1 and Q2. 3. Add your name and studentID as comments on the top of each Java source file you submit. Question 1. Bookings APP [80 Points-six parts] Implement the following hotel booking system. Use the following class diagram to understand the structure of the system's classes, their attributes operations (or methods),...

  • can you help me with the answers to questions 3-10? Merge & Center - S -...

    can you help me with the answers to questions 3-10? Merge & Center - S - % ) 38- Insert Delete com Conditional Formatas Cell Formatting Table - Styles Styles Alignment Number Clipboard 166 Font x ve Supervision $1,700,000 1,000 850 3,500 HT 5350 S 317.76 $ 317,757.01 225 666.67 $ 100,000.00 SOS770 $ 14.11 $3,314,030.08S Supplies Units manufacture 150 110 $190,000 $8,550,000 25 Total 234,300 175,420 191.550 Questions: 3. Use activity based costing to allocate the costs of overhead...

  • Project 3 Objective: The purpose of this lab project is to exposes you to using menus,...

    Project 3 Objective: The purpose of this lab project is to exposes you to using menus, selection writing precise functions and working with project leaders. Problem Specification: The PCCC Palace Hotel needs a program to compute and prints a statement of charges for customers. The software designer provided you with the included C++ source and you are asked to complete the code to make a working program using the given logic. The function main () should not change at all....

  • Part B (BI). Implement a Red-Black tree with only operation Insert(). Your program should read from...

    Part B (BI). Implement a Red-Black tree with only operation Insert(). Your program should read from a file that contain positive integers and should insert those numbers into the RB tree in that order. Note that the input file will only contain distinct integers. Print your tree by level using positive values for Black color and negative values for Red color Do not print out null nodes. Format for a node: <Node_value>, <Parent_value>). For example, the following tree is represented...

  • As the manager of a local chain of coffeehouses, you have been asked to speak to...

    As the manager of a local chain of coffeehouses, you have been asked to speak to a gourmet group about how to make genuine Italian cappuccino. As you write down your ideas for your speech, you find that you have the following main points. 1.       First you must make the espresso. 2.       Grind the coffee beans so they are fine but not too fine. 3.       Place the grounds coffee in the filter holder of the espresso machine. 4.       Taps the coffee once lightly to...

  • C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose...

    C++ please Let's pretend that we can still go out to eat at a restaurant. Suppose we have the job to make a program that accepts a dinner reservation. The information collected will be the name of the customer, the date for the reservation, the time for the reservation (good choice for a hierarchical struct), the number in the party, email address (for updates) and phone number. Define a hierarchical structure for a dinner reservation that will contain the above...

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