Question: Create a program that allows you to view and edit the sales amounts for each month of the current year. The program will use a

Create a program that allows you to view and edit the sales amounts for each month of the current year.
The program will use a dictionary to store the data instead of a list. Follow the formatting shown in the
sample output
Montly sales txt
Jul 1762
Dec 497
May 2429
Mar 1073
Apr 3452
Oct 3734
Aug 2547
Jun 1324
Feb 2176
Nov 984
Jan 616
Sep 1444
Console
Monthly Sales program
COMMAND MENU
view - View sales for specified month
edit - Edit sales for specified month
totals - View sales summary for year
exit - Exit program
Command: view
Three-letter Month: Jan
Sales amount for Jan is 616.00.
Command: edit
Three-letter Month: Jan
Sales Amount: 651
Sales amount for Jan is 651.00.
Command: totals
Yearly total: 22,038
Monthly average: 1,836.5
Command: view
Three-letter Month: July
Invalid three-letter month.
Command: exit
Bye!
Specifications
Use the text file named monthly_sales.txt that consists of tab delimited rows, where the rows
contain three-letter abbreviations for the month and the monthly sales. Create a module level
constant to hold the name of the text file.
The program should contain a function that reads the file and store the sales data for each
month in a dictionary with the month abbreviation as the key for each sales value item. For
each line of text in the file remove the new line character and split the tab delimited row into
a list that is used to create the dictionary elements. This function will return the dictionary
of all key/value elements.
The program should contain a function that writes the dictionary values to the file. The
dictionary will be passed to the function as a parameter. For each month and sales amount
key value pair in the dictionary write a tab separated line to the text file.
Whenever the sales data is edited, the program should write the changed data to the text file.
When viewing or editing a month, check if the input month is a valid key in the dictionary and
display a message if the three-letter month is not valid.
Use functions to organize the code for each of the commands. monthly_sales.txt
\begin{tabular}{ll}
Jul & 1762\\
Dec & 497\\
May & 2429\\
Mar & 1073\\
Apr & 3452\\
Oct & 3734\\
Aug & 2547\\
Jun & 1324\\
Feb & 2176\\
Nov & 984\\
Jan & 616\\
Sep & 1444
\end{tabular}
Create a program that allows you to view and edit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!