2. Sales Report - PSEUDOCODE 15 PTS + PYTHON 20 PTS Brewster’s Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has provided a file that contains sales records for each salesperson for the past month. Each record in the file contains the following two fields: ● The salesperson’s ID number, as an integer ● The amount of a sale, as a real number Programming Exercises Programming Exercises 427 The records are already sorted by salesperson ID. Brewster wants you to design a program that prints a sales report. The report should show each salesperson’s sales and the total sales for that salesperson. The report should also show the total sales for all salespeople for the month. Here is an example of how the sales report should appear: Brewster's Used Cars, Inc. Sales Report Salesperson ID Sale Amount ====================================== 100 $10,000.00 100 $12,000.00 100 $5,000.00 Total sales for this salesperson: $27,000.00 101 $14,000.00 101 $18,000.00 101 $12,500.00 Total sales for this salesperson: $44,500.00 102 $13,500.00 102 $14,500.00 102 $20,000.00 Total sales for this salesperson: $48,000.00 Total of all sales: $119,500.00
PYTHON CODE NOT JAVA PLEASE
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
def read_file_data(filename): with open(filename,'r') as infile: employee_dict={} for line in infile.readlines(): line=line.strip().split() if employee_dict.get(line[0].strip()) == None: amount=[] amount.append(eval(line[1])) employee_dict[line[0]]=amount else: amounts=employee_dict.get(line[0].strip()) amounts.append(eval(line[1])) return employee_dict def output(employeeDetails): print('Brewster\'s Used Cars, Inc.') print('Sales Report\n') print('{0:<25}{1:>20}'.format('Salesperson ID','Sale Amount')) total_amount=0 print('='*45) for employee, amounts in employeeDetails.items(): for amount in amounts: print('{0:<25}{1:>20}'.format(employee,'${0:,.2f}'.format(amount))) print('Total sales for this salesperson: ${0:,.2f}'.format(sum(amounts))) print() total_amount+=sum(amounts) print('Total of all sales: ${0:,.2f}'.format(total_amount)) def main(): employeeData=read_file_data('brewster.dat') output(employeeData) main()
Kindly revert for any queries
Thanks.
2. Sales Report - PSEUDOCODE 15 PTS + PYTHON 20 PTS Brewster’s Used Cars, Inc. employs...
I need a simple python code Brewster’s Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has provided a file that contains sales records for each salesperson for the past month. Each record in the file contains the following two fields: The salesperson’s ID number, as an integer The amount of a sale, as a real number The records are already sorted by salesperson ID. Brewster wants you to develop a program that prints a sales report....