In: Computer Science
FOR PYTHON:
Write a python program for a car salesperson who works a five day week. The program should prompt for how many cars were sold on each day and then prompt for the selling price of each car (if any) on that day. After the data for all five days have been entered, the program should report the total number of cars sold and the total sales for the period. See example output. NOTE: duplicate the currency format shown for the total sales,
Example Output How many cars were sold on day 1? 1
Selling price of car 1? 30000
How many cars were sold on day 2? 2
Selling price of car 1? 35000
Selling price of car 2? 45000
How many cars were sold on day 3? 0
How many cars were sold on day 4? 1
Selling price of car 1? 30000
How many cars were sold on day 5? 0
You sold 4 cars for total sales of $140,000.00
totalCars = 0
totalSales = 0
for i in range(5):
n = int(input("How many cars were sold on day "+str(i+1)+"?
"))
totalCars = totalCars + n
for j in range(n):
price = int(input("Selling price of car "+str(j+1)+"? "))
totalSales = totalSales + price
print("You sold "+str(totalCars)+" cars for total sales of
$"+str('{:20,.2f}'.format( float(totalSales) )))
Output:
sh-4.3$ python3 main.py
How many cars were sold on day 1? 1
Selling price of car 1? 30000
How many cars were sold on day 2? 2
Selling price of car 1? 35000
Selling price of car 2? 45000
How many cars were sold on day 3? 0
How many cars were sold on day 4? 1
Selling price of car 1? 30000
How many cars were sold on day 5? 0
You sold 4 cars for total sales of $ 140,000.00