Question: Page 1 of 2 Monthly Sales program COMMAND MENU monthly - View monthly sales yearly - View yearly summary edit - Edit sales for a
Page
of
Monthly Sales program
COMMAND MENU
monthly View monthly sales
yearly View yearly summary
edit Edit sales for a month
exit Exit program
Command: monthly
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec NA
Command: yearly
Using sales amount of for Dec.
Yearly total:
Monthly average:
Command: edit
Threeletter Month: Noc
Invalid threeletter month.
Command: edit
Threeletter Month: Nov
Sales Amount:
Sales amount for Nov was modified.
Command: exit
Bye!
Chapter Monthly Sales
Add exception handling to the Chapter program that reads the sales for months from a file
and calculates the total yearly sales as well as the average monthly sales.
Console
Specifications
If the program cant find the CSV file when it starts, display an error message, and exit
the program. Use appropriate error handling to prevent a runtime error when the file is
missing.
Use the CSV file named monthlysales.csv that contains the month and sales data shown
above. Represent the file name in a constant.
Write a function to open file and read the CSV file. This function will not have a parameter.
Each row in the file will be turned into a list that holds the month and sales value for the
month. Each row list will be added to a list that is returned by the function.
Create a function that saves the monthly sales list to the CSV file. This function will take a
list as a parameter. The read and write functions belong in the same module from chapter
Create functions for the monthly, yearly, and edit commands. The functions will
take the sales list as an input parameter. Call each function from an if statement in
the main method.
The main method will call the function that reads the file to store the list of lists in
the monthly sales list.
The edit function will call the function that writes to the CSV file immediately after
any change to the list is completed.
The yearly function will dynamically calculate the average based on the total of all
sales values in the list and the length of the list. Round the results of the monthly
average to a maximum of decimal digits. Formatting is not required.
In the yearly function, if the sales list doesnt contain a valid integer for the sales
amount for any month, use a value of for that month only when calculating the
total sales for the year. Display a message to the user when this happens.
The edit function will ask the user for the threeletter month and sales value and
make a simple list of these two values. This simple new list will replace the current
single month list in the sales list.
For the edit function, display an error message if the user doesnt enter a valid
threeletter abbreviation for the month. Use the following list as the standard
abbreviations.
months Jan 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
