Question & Answer: sample Run: Enter type of vehicle (car/truck): car Number of vehicles: 1 Money Collected: $1.00 Do you w…..

sample Run: Enter type of vehicle (car/truck): car Number of vehicles: 1 Money Collected: $1.00 Do you want to enter more vehicles (Y/N)? Y Enter type of vehicle (car/truck): truck Number of vehicles: 2 Money Collected: $3.00 Do you want to enter more vehicles (Y/N)? NQuestion & Answer: sample Run: Enter type of vehicle (car/truck): car Number of vehicles: 1 Money Collected: $1.00 Do you w..... 1

Urgent please help. Python 3 thank you

sample Run: Enter type of vehicle (car/truck): car Number of vehicles: 1 Money Collected: $1.00 Do you want to enter more vehicles (Y/N)? Y Enter type of vehicle (car/truck): truck Number of vehicles: 2 Money Collected: $3.00 Do you want to enter more vehicles (Y/N)? N

Expert Answer

 

Python 3 code:

class Register:
number_of_vehicles = 0;
money = 0;
def __init__(self):
pass
def setcount(self,incr):
Register.number_of_vehicles += incr
def settally(self,incr):
Register.money += incr
def getcount(self):
return Register.number_of_vehicles
def gettally(self):
return Register.money
def processcar(self,n):
self.setcount(n);
self.settally(n*1);
print(“Number of Vehicles = “, self.getcount())
print(“Money collected = $”, self.gettally())
def processtruck(self,n):
self.setcount(n);
self.settally(n*2);
print(“Number of Vehicles = “, self.getcount())
print(“Money collected = $”, self.gettally())

R1 = Register()
while(True):
print(“Enter Type of vehicle (car/truck)”);
v = (input().strip()).lower()
if(v == “car”):
tmp = 1
R1.processcar(tmp)
elif(v == “truck”):
tmp = 1
R1.processtruck(tmp)
else:
print(“Invalid vehicle!”)
print(“Do you want to enter more vehicles!(y/n)”)
m = (input().strip()).lower()
if(m == ‘y’):
continue
else:
break

Sample Run:

Enter Type of vehicle (car/truck)
 truck
Number of Vehicles =  1
Money collected = $ 2
Do you want to enter more vehicles!(y/n)
 y
Enter Type of vehicle (car/truck)
 truck
Number of Vehicles =  2
Money collected = $ 4
Do you want to enter more vehicles!(y/n)
 y
Enter Type of vehicle (car/truck)
 car
Number of Vehicles =  3
Money collected = $ 5
Do you want to enter more vehicles!(y/n)
 n
Still stressed from student homework?
Get quality assistance from academic writers!