[Solved] Revenue Problem with Python

Prathap, a student event organiser is organizing an Exhibition and a Stage event in his college fest. His Job was to calculate the revenue of the event. There were many stalss in the exhibition and many shows booked for the stage events as well and he was running out of time. so he thinks of quicly writing a code which would take all the event details from the user and calculate the revenue of that event. He provides choice to the user to choose between 1. Exhibition and 2. Stage Event. Let’s help Prathap in writing the code.
Write python program to calculate revenue by overriding the projectedRevenue() method.

    Create a parent class Event with following attributes

AttributesDatatype
namestr
detailstr
owner_namestr


    Then create child class Exhibition that inherites Event with the following attribute, 

AttributesDatatype
no_of_stallint


    And create another child class StageEvent that inherites Event with the following attribute, 

AttributesDatatype
no_of_showsint
no_of_seats_per_showint


     Add method projectedRevenue() in parent and its child class. 

MethodDescription
projected_revenue()calculate revenue and print the  value.


    Note: For Exhibition , each stall will produce Rs.10000 as revenue. For StageEvent, each seat produces Rs.50 revenue.
                 Print “Invalid Choice” if any other is choosen other than 1 and 2.

    Refer sample input/output for other further details and format of the output.

[All Texts in bold corresponds to the input and rest are output]

Sample Input/Output 1:


Enter the name of the event:
Science Fair
Enter the detail of the event:
Explore Technology
Enter the owner name of the event:
Abhi
Enter the type of the event:
1.Exhibition
2.StageEvent
1
Enter the number of stalls:
65
The projected revenue of the event is 650000.0

Sample Input/Output 2:

Enter the name of the event:
Magic Show
Enter the detail of the event:
See Magic without Logic
Enter the owner name of the event:
Shashi
Enter the type of the event:
1.Exhibition
2.StageEvent
2
Enter the number of shows:
10
Enter the number of seats per show:
100
The projected revenue of the event is 50000.0

Solution

class Event:
    
    def __init__(self, name, detail, owner_name):
        self.name = name
        self.detail = detail
        self.owner_name = owner_name

    def projectedRevenue(self):
        pass


class Exhibition(Event):

    def __init__(self, name, detail, owner_name, no_of_stall):
        self.name = name
        self.detail = detail
        self.owner_name = owner_name
        self.no_of_stall = no_of_stall

    def projectedRevenue(self):
        return self.no_of_stall * 10000


class StageEvent(Event):

    def __init__(self, name, detail, owner_name, no_of_shows, no_of_seats_per_show):
        self.name = name
        self.detail = detail
        self.owner_name = owner_name
        self.no_of_shows = no_of_shows
        self.no_of_seats_per_show = no_of_seats_per_show

    def projectedRevenue(self):
        return self.no_of_shows * self.no_of_seats_per_show * 50


print("Enter the name of the event:")
name = raw_input()
print("Enter the detail of the event:")
detail = raw_input()
print("Enter the owner name of the event:")
owner_name = raw_input()
print("Enter the type of the event:")
print("1.Exhibition")
print("2.StageEvent")
choice = int(input())
if choice == 1:
    print("Enter the number of stalls:")
    no_of_stall = int(input())
    event = Exhibition(name, detail, owner_name, no_of_stall)
    print("The projected revenue of the event is {:.1f}".format(
        event.projectedRevenue()))
elif choice == 2:
    print("Enter the number of shows:")
    no_of_shows = int(input())
    print("Enter the number of seats per show:")
    no_of_seats_per_show = int(input())
    event = StageEvent(name, detail, owner_name,
                       no_of_shows, no_of_seats_per_show)
    print("The projected revenue of the event is {:.1f}".format(
        event.projectedRevenue()))
else:
    print("Invalid Choice")

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saransh Saurav

Saransh Saurav

Articles: 67

Leave a Reply

Your email address will not be published. Required fields are marked *