Write a Python program that calculate and summarize the sales of every day and finds out who are the best employee who made more profits.
For simplicity: We assume that the program works for only two days and for only two employees. i.e. the program collects and summarize the sales of only two days for only two employees
The program accepts undefined number of sales for each employee.
For example: You could assume in the first day the first
employee made 5 sales and the second employee made 3 sales.
Similarly, in the second day you can assume any random number of
sales for each employee.
The amount of each sales also can be chosen randomly as an integer
number.
The program starts collecting data in the following order:
User can move from (a) to (b) to (c) and finally to (d) by entering 0 (zero) value. The last entered zero will print the summary. The summary shows total sales per day and total sales per employee, and best employee for each day, that is the employee who achieves more sales in amount of money, not in number of sales.
Assume that the total sales would never be the same for both employee, i.e. one of the employee always sells more than the other. Either the first employee will sell more than the second employee, or the second employee will sell more than the first employee.
Also, assumes that the user doesn’t do any mistakes in the entry of the data.
The main function should start with the following:
sales={
'd1':{
'e1':{'sls':[]},
'e2':{'sls':[]}},
'd2':{
'e1':{'sls':[]},
'e2':{'sls':[]}}}
It is the declaration of ‘sales’ dictionary. As you can see, it is a multidimensional dictionary that can contain the sales of two employees in two days.
The program should use loops to produce the results of totals and winner employee.
For example:
Assume we have the following dictionary:
sales={‘d1’:2, ‘d1’:3}
Then finding the total of sales as follows is not accepted:
Sales = {'d1':2, 'd2':3}
TotalSales = sales['d1'] + sales['d2']
The accepted form of solution to find the total sales must use loops as shown below or in a similar way as long as it uses loops:
TotalSales = 0
for k, v in sales.items():
TotalSales += v
Similar to the example above, the program should use loops to produce the results of total per employee and the total per day, and the winner employee.
You must use loops.
Below is an example of how the program runs:
Enter a sale in d1 for e1 or 0 to move to next employee or day: 1
Enter a sale in d1 for e1 or 0 to move to next employee or day: 2
Enter a sale in d1 for e1 or 0 to move to next employee or day: 3
Enter a sale in d1 for e1 or 0 to move to next employee or day: 4
Enter a sale in d1 for e1 or 0 to move to next employee or day: 5
Enter a sale in d1 for e1 or 0 to move to next employee or day: 0
Enter a sale in d1 for e2 or 0 to move to next employee or day: 6
Enter a sale in d1 for e2 or 0 to move to next employee or day: 1
Enter a sale in d1 for e2 or 0 to move to next employee or day: 2
Enter a sale in d1 for e2 or 0 to move to next employee or day: 0
Enter a sale in d2 for e1 or 0 to move to next employee or day: 4
Enter a sale in d2 for e1 or 0 to move to next employee or day: 5
Enter a sale in d2 for e1 or 0 to move to next employee or day: 0
Enter a sale in d2 for e2 or 0 to move to next employee or day: 7
Enter a sale in d2 for e2 or 0 to move to next employee or day: 8
Enter a sale in d2 for e2 or 0 to move to next employee or day: 9
Enter a sale in d2 for e2 or 0 to move to next employee or day: 0
Summary of the sales:
Employee1 Employee2 total Winner
----------------------------------------------
Day1 15 9 24 Emp 1
Day2 9 24 33 Emp 2
----------------------------------------------
Total 24 33
Note: the above run of the program is an example. The program should be able to work with random number of sales and random amount of money for each sale. Also, it should print the correct totals and winners of highest sales per day.
The program should use the exact names suggested in the given dictionary and in the given example. And the program should produce the same text used in the example above. Notice the spaces and insert the proper ‘\n’ newlines as illustrated in the example.
# Python Code
sales={
'd1':{
'e1':{'sls':[]},
'e2':{'sls':[]}},
'd2':{
'e1':{'sls':[]},
'e2':{'sls':[]}}}
zero_counter = 0 # Counter to count the number of zeros
while(zero_counter!=4):
if zero_counter == 0:
sale = int(input('Enter a sale in d1 for e1 or 0 to move to next employee or day:'))
if sale == 0:
zero_counter += 1
else:
sales['d1']['e1']['sls'].append(sale)
elif zero_counter == 1:
sale = int(input('Enter a sale in d1 for e2 or 0 to move to next employee or day:'))
if sale == 0:
zero_counter += 1
else:
sales['d1']['e2']['sls'].append(sale)
elif zero_counter == 2:
sale = int(input('Enter a sale in d2 for e1 or 0 to move to next employee or day:'))
if sale == 0:
zero_counter += 1
else:
sales['d2']['e1']['sls'].append(sale)
else:
sale = int(input('Enter a sale in d2 for e2 or 0 to move to next employee or day:'))
if sale == 0:
zero_counter += 1
print('Summary of the sales:')
e1_sales = [] # To store total sales per day for e1
e2_sales = [] # To store total sales per day for e2
winner = [] # To store winner of the day
total = []
# For loop to calculate total sales per day for each employee
for day in sales:
e1_sales.append(sum(sales[day]['e1']['sls']))
e2_sales.append(sum(sales[day]['e2']['sls']))
if sum(sales[day]['e1']['sls']) > sum(sales[day]['e2']['sls']):
winner.append('Emp 1')
else:
winner.append('Emp 2')
total.append(sum(sales[day]['e1']['sls']) + sum(sales[day]['e2']['sls']))
print('\tEmployee1\tEmployee2\ttotal\tWinner')
for i in range(len(e1_sales)):
print('Day' + str(i+1) + '\t' + str(e1_sales[i]) + '\t\t' + str(e2_sales[i]) + '\t\t' + str(total[i]) + '\t' + str(winner[i]))
else:
sales['d2']['e2']['sls'].append(sale)
Code Image:


Input/Output image:

Please Like If Your Problem is solved!
Write a Python program that calculate and summarize the sales of every day and finds out...
Java.
Please write the output
import java.util.Scanner; import java.text.Decimalformat: * This program demonstrates two-dimensional array. public class CorpSales public static void main(String[] args) Final int DIVS - 3; // Three divisions in the company final int QTRS = 4; // Four quarters double totalSales - e.e; / Accumulator // Create an array to hold the sales for each // division, for each quarter. double[][] sales - new double[DIVS][QTRS] // Create a Scanner object for keyboard input. Scanner keyboard = new...
Python 3.6 "While Loops" Write a program that adds up a series of numbers entered by the user. The user should enter each number at the command prompt. The user will indicate that he or she is finished entering the number by entering the number 0. Example This program will sum a series of numbers. Enter the next number (enter 0 when finished) > 5 Enter the next number (enter 0 when finished) > 2 Enter the next number (enter...
Write a C++ program that will calculate the total amount of money for book sales at an online store. For each sale, your program should ask the number of books sold and then the price for each book and the shipping method (‘S’ for standard shipping and ‘E’ for expedited shipping). The program will produce a bill showing the subtotal, the sales tax, the discount, the shipping charge, and the final total for the sale. The program will continue processing...
For this problem, assume salesperson data are stored in a database table named staff. Also assume the columns in the table are named name, carsSold, and totalSales Write a Python function named getSalesSortedByNames. Your function will have 2 parameters. The first parameter is a database cursor and the second parameter is a float. Your function should start by retrieving those rows in the staff table whose totalsales field is equal to the second parameter. (The next paragraph shows the Python...
USING PYTHON: Write a program that reads an unspecified number of integers and finds the ones that have the most occurrences. For example, if you enter 2 3 40 3 5 4 –3 3 3 2 0, the number 3 occurs most often. Enter all numbers in one line. If not one but several numbers have the most occurrences, all of them should be reported. For example, since 9 and 3 appear twice in the list 9 30 3 9...
This is JAVA. Must write a short description of this program, usually a sentence or two will be sufficient. All the classes, methods and data fields should be clearly documented (commented). Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of...
12. Bar Chart Write a program that asks the user to enter today’s sales for five stores. The program should display a bar chart comparing each store’s sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Here is an example of the program’s output: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Enter today's sales for store 3: 1800 [Enter]...
Assignment: Write a program that asks the user to enter today’s sales for five stores. The program should then display a bar chart comparing each store’s sales. Create each bar in the bar chart bydisplaying a row or asterisks. Each asterisk should represent $100 of sales. You must use a loop to print the bar chart. If the user enters a negative value for the sales amount, the program will keep asking the user to enter the sales amount until...
Answer using C++ Write a program that will calculate the final sales price of a motorcycle; this includes additional optional packages along with sales tax. You may assume that the base? price of the motorcycle is $30,000. First you must ask the user to choose which optional packages they want. The user is only permitted to choose one package. Your program should display a menu of the available packages. The user should enter the package by entering the letter associated...
Write them in python IDLE *****
5. Average Rainfall
Write a program that uses nested loops to collect data
and calculate the average rainfall over a period of years. The
program should first ask for the number of years. The outer loop
will iterate once for each year. The inner loop will iterate twelve
times, once for each month. Each iteration of the inner loop will
ask the user for the inches of rainfall for that month. After all
iterations,...