Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Oliver King XXXXXXXXXX April 2021 King Scoopers $-87.44 Forever21 $-244.9 Payroll $1899.21 Blue Pan Pizza $-38.49 Uber $-12.0 Deposite $150.88 CSC Project Create a Banking/Budget software. The program...

1 answer below »
Oliver King
XXXXXXXXXX
April 2021
King Scoopers $-87.44
Forever21 $-244.9
Payroll $1899.21
Blue Pan Pizza $-38.49
Uber $-12.0
Deposite $150.88

CSC Project
Create a Banking/Budget software. The program will allow the user to keep track of his balance and monthly incomes/expenses. The user will be able to perform various operations: check balance, add income, add an expense, check monthly total, view a monthly statement, and save a monthly statement to a file.
The program should be
oken down into a set of functions, each will perform a specific task. Following is a list of the functions and their descriptions. Write your functions in the order specified in this document. The assignment will be graded by functions. See the final project ru
ic for more information.
Make sure to follow the instructions and function specifications carefully. Each function is described with the parameters it takes, the values it returns, and its task. Your functions should match those descriptions.
Functions:
Main():
Prompt the user for a file name and call the ReadFile function with that file name to read the data from the text file into the program.
In a loop, call the Menu() function continuously to allow the user to perform different operations until he chooses to exit.
Call the co
ect function to perform the chosen operation based on the user choice returned from the Menu() function. Print balance if the user chooses to check balance. Add income/expense if the user chooses to. Print monthly total if the user chooses that option. Print statement or save statement to file if the user chooses those options.
When the user chooses to exit, make sure to save the updated data to the text file before terminating the program. When the user opens the program next time it will have the information that was updated by him.
ReadFile(filename):
· Parameter: the name of the file with the data (example file attached).
· Return: the data from the file in data structures to your choice.
• Task: read the data from the text file and store it in variables in an organized way. The first line contains the name of the user, the second line contains the balance amount, the third line contains the cu
ent month and year, and each of the following lines contains an expense/income name followed by its amount (negative for expense, positive for income). I would recommend storing the name in a single variable, the balance in a single variable, the month in a single variable, and use either a dictionary or two parallel lists for the incomes/expenses (Hint: you may want to split the income/expense lines by the symbol that appears right before the number).
Menu():
· Parameter: none.
· Return: user choice of operation. An integer.
· Task: print a menu showing the user the operations they can perform: check balance,
add income, add an expense, check monthly total, view monthly statement, save monthly statement to file, or exit. Prompt the user to choose one from the above (each should be associate with a number and the user should enter the number of the option). Return the integer representing the operation the user chose.
CheckBalance(balance):
· Parameters: the account balance
· Return: nothing
· Task: print the account balance with the dollar sign and two decimal places.
AddIncome(data):
· Parameters: data: the data structure/s with the incomes/expenses.
· Return: amount of income added (integer).
· Task: Prompt the user for the name and the amount of the income. Add it to the
monthly income/expenses in the data structure. If the income already exists you should just add to its amount and not create a new entry for it. Return the income amount to be added to the balance.
AddExpense(data):
· Parameters: data: the data structure/s with the incomes/expenses.
· Return: amount of expense added (integer).
· Task: Prompt the user for the name and the amount of the expense. Add it to the
monthly income/expenses in the data structure (as a negative number). If the expense already exists you should just add to its amount and not create a new entry for it. Return the expense amount to be subtracted from the balance.
MonthlyTotal(data):
· Parameters: data: the data structure/s with the incomes/expenses.
· Return: nothing.
· Task: Add the amounts from all the monthly incomes/expenses to a total and print it
with the dollar sign and two decimal places.
*note: the monthly total is NOT the balance. The incomes/expenses are from the cu
ent month only. The monthly total is the sum of the incomes/expenses amounts.
PrintStatement(data):
· Parameters: data: all the data needed to be printed
· Return: nothing.
· Task: Print the monthly statement to the console. Should have the name of the user and
the month at the top, a header saying Monthly statement, column headers for name and amount, all the incomes/expenses names listed under names with their co
esponding amounts listed under amount, and the balance at the bottom. An example output is shown below.
StatementToFile(data):
· Parameters: data: all the data needed to be saved t o file
· Return: nothing.
· Task: Prompt the user for the name of the output file. Write the monthly statement to
the file. The same output as PrintStatement only written to file. NewMonth(month, data):
· Parameters: month: the ending month (and year), data: dictionary/lists with incomes/expenses.
· Return: the new month
· Task: Write the ending month to a file with the name of the month (plus extension).
Create and return a variable with the following month (April 2019 -> May XXXXXXXXXXClear the dictionary to start the new month without any incomes/expenses.
ChangeName():
· Parameters: None
· Return: the new name
· Task: Prompt the user for a new name and return it (to be assigned to the name
variable). SaveToFile():
• Parameters: data: all necessary data to be saved to the file as well as the filename (same file name you read data from)
· Return: the new name
· Task: Prompt the user for a new name and return it (to be assigned to the name
variable).
If __name__ == “__main__”: Entry point to the program. Calls the main function.
Sample Output:
Input data file example:
Output files: Output.txt
April 2021.txt
data.txt after the program ran:
Answered 1 days After Aug 09, 2021

Solution

Aniket answered on Aug 10 2021
139 Votes
'READ FILE FUNCTION'
def ReadFile(filename):
dic={'Name':'','Balance':0,'Month':'','Year':0,'TransDict':{}}
f = open("abc.txt", "r")
l=[]
l=f.readlines()
f.close()
for i in range(len(l)):
if l[i][-1]=="\n":
l[i]=l[i][:-1]

dic={'Name':'','Balance':0,'Month':'','Year':0,'TransDict':{}}
dic['Name']=l[0]
dic['Balance']=float(l[1])
v=l[2].split()
dic['Month']=v[0]
dic['Year']=int(v[1])
MonthTransDict={}
if len(l)>3:
for i in range(3,len(l)):
v=l[i].split()
l[i]=""
for j in range(len(v)-1):
l[i]=l[i]+v[j]+' '
l[i]=l[i][:-1]
MonthTransDict[l[i]]=float(v[-1].lstrip('$'))
dic['TransDict'][dic['Month']]=MonthTransDict
return dic

'CHECK BALANCE FUNCTION'
def CheckBalance(balance):
print('\nAccount balance is: $'+str(balance))

'ADD INCOME FUNCTION'
def AddIncome(filedata):
name=input('\nEnter income name: ')
amt=int(input('\nEnter income amount: '))
month=filedata['Month']
if name not in filedata['TransDict'][month]:
filedata['TransDict'][month][name]=amt
else:
filedata['TransDict'][month][name]=filedata['TransDict'][month][name]+amt
return amt

'ADD EXPENSE FUNCTION'
def AddExpense(filedata):
name=input('\nEnter expense name: ')
amt=int(input('\nEnter expense amount: '))
month=filedata['Month']
if name not in filedata['TransDict'][month]:
filedata['TransDict'][month][name]=-amt
else:
filedata['TransDict'][month][name]=filedata['TransDict'][month][name]-amt
return amt
'CHECK CURRENT MONTHLY TOTAL FUNCTION '
def...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here