WeCare insurance company wants to calculate premium of vehicles. Vehicles are of two types – “Two-Wheeler” and “Four-Wheeler”. Each vehicle is identified by vehicle id, type, cost and premium amount. Premium amount is 2% of the vehicle cost for two wheelers and 6% of the vehicle cost for four wheelers. Calculate the premium amount and display the vehicle details. Write a Python program to implement the class chosen with its attributes and methods.

class vehicle:


    def _init_(self):


        self.__vehicleid=None


        self.__vehicletype=None


        self.__vehiclecost=None


        self.__vehiclepremium=None


    def setvehicleid(self,vid):


        self.__vehicleid=vid


    def setvehicletype(self,typ):


        self.__vehicletype=type


    def setvehiclecost(self,cost):


        self.__vehiclecost=cost


    def setvehiclepremium(self):


        if(self.__vehicletype=="two wheeler"):


            self.__vehiclepremium=self.__vehiclecost*2/100


            print("premium for two wheeler",self.__vehiclepremium)


        elif(self.__vehicletype=="four wheeler"):


            self.__vehiclepremium=self.__vehiclecost*6/100


            print("premium for four wheeler",self.__vehiclepremium)


        else:


            print("u enterd invalid vehicle")


    def getvehicleid(self):


        return self.__vehicleid


    def getvehicletype(self):


        return self.__vehicletype


    def getvehiclecost(self):


        return self.__vehiclecost


wecare=vehicle()


vid=input("enter vehicle id")


wecare.setvehicleid(vid)


type=input("enter type")


wecare.setvehicletype(type)


cost=int(input("enter cost"))


wecare.setvehiclecost(cost)


print("vehicle id",wecare.getvehicleid())


print("vehicle type",wecare.getvehicletype())


print("vehicle cost",wecare.getvehiclecost())


wecare.setvehiclepremium()


Comments

Popular posts from this blog

Write a python program to compute cumulative product of a list of numbers (write function cumulative_product).

Write a Python program to compute distance between two points taking input from the user. Formula for Pythagorean theorem for compute distance between two points is: