Knowee
Questions
Features
Study Tools

Given the weights(kg.) of each luggage of a customer as input in an airport check-in process. If the sum of weights is less than 15kg then permit the passenger.Else given an user defined exception

Question

Given the weights(kg.) of each luggage of a customer as input in an airport check-in process. If the sum of weights is less than 15kg then permit the passenger.Else given an user defined exception

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a Python solution for your problem:

class WeightLimitExceededError(Exception):
    """Exception raised when the weight limit is exceeded."""
    pass

def check_in(luggage_weights):
    """Check in a customer, given the weights of their luggage."""
    # Calculate the total weight of the luggage
    total_weight = sum(luggage_weights)
    # If the total weight is less than 15kg, permit the passenger
    if total_weight < 15:
        return "Passenger permitted"
    # If the total weight is more than 15kg, raise an exception
    else:
        raise WeightLimitExceededError(f"Total luggage weight {total_weight}kg exceeds the limit")

# Example usage:
try:
    print(check_in([5, 5, 5]))  # This will raise an exception
except WeightLimitExceededError as e:
    print(e)

try:
    print

This problem has been solved

Similar Questions

At the airport, each piece of luggage to be checked in must not weigh more than 50 pounds.Use w to represent the weight (in pounds) of a piece of luggage that can be checked in.

A shipping company charges the shipping cost of $10 per kg for packages weighing equal to 5 kg. For packages weighing more than 5 kg but less than 11 kg, the shipping cost is $8 per kg. On a certain day, the company shipped a total of 140 packages and earned $8760. The total weight of the packages was 1020 kg. Maximum how many packages could weigh 6 kg? (Assume all packages have integral weight of more than or equal to 5 kg.)1)  602)  323)  244)  20

A family is going on vacation and they are packing their bags for their flight. They have packed four bags which weigh (in kg) 16, 17, 21, and 26. They need to pack one more bag. Write an inequality to represent the weights the next bag could have so that the average (mean) is lower than 22. Use x to represent the weight of the next bag. Simplify your answer as much as possible.

Eli is packing for her holiday. She can bring 23 kg in total and has already packed 2 pairs of boots that each weigh 1.2 kg a pair. She has also packed her toiletry bag, which weighs 0.7 kg.If the suitcase itself weighs 3.5 kg, how much more luggage can she pack?

A shipping container will be used to transport several 60-kilogram crates across the country by rail. The greatest weight that can be loaded into the container is 24500 kilograms. Other shipments weighing 14600 kilograms have already been loaded into the container. Write and solve an inequality which can be used to determine xx, the number of 60-kilogram crates that can be loaded into the shipping container.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.