58.6k views
2 votes
Selling a new vehicle pays a salesperson $1500. Selling a used vehicle pays a commission of 5% of the selling price. Write an interactive program that calculates a salesperson's total pay for selling two vehicles, each one of any type. The program should prompt the salesperson to enter the type and selling price of each vehicle. Do not use a loop. The program should then display the salesperson's total sales and total pay. Express these amounts in currency format as described in the requirements above.

User Barnardh
by
5.2k points

1 Answer

2 votes

Answer:

#Selling vehicles

import locale

locale.setlocale( locale.LC_ALL, 'en_CA.UTF-8' )

#Declaration of variables

total_pay=0

total_sales=0

#Selling details

for i in range(0,2):

#Ask the type of sell

type=input("Enter the type of the car you sold(used/new)? ")

#Check error

while(type.upper()!="USED" and type.upper()!="NEW"):

print('ERROR!!!Should be used or new!!Please Re-enter')

type=input("Enter the type of the car you sold(used/new)? ")

#Input price of the car

price=float(input("Enter the price of the car: "))

#Calculations

if(type.upper()=="NEW"):

total_pay+=1500

else:

total_pay+=price*.05

total_sales+=price

#Display results

print('Total Pay of the sale person = ',locale.currency(total_pay))

print('Total Sales = ',locale.currency(total_sales))

User Takiyah
by
5.7k points