Question Details - 350 Karma Points For the petty cash program below, please add
ID: 3619857 • Letter: Q
Question
Question Details - 350 Karma Points For the petty cash program below, please add new capabilities. 1. Add further attributes to the Account class (account's name, belong to which department, responsible person's name, title, phone number, email address, etc) 2. Create a list of accounts. Let the user add new accounts to the list. 3. Ask the user for the name of an account and then print the account's details.----------------------------
import shelve import string import datetime class Transaction: DateOfTransaction = datetime.datetime(1900,1,1).today(); TypeOfTransaction = ""; FinalBalance = ""; def __init__(self, TypeOfTransaction,FinalBalance): self.TypeOfTransaction =TypeOfTransaction; self.FinalBalance = FinalBalance; def showTransaction(self): if(self.TypeOfTransaction!="View transactions"): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); def showRequest(self): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); class Account: balance = 0.0; transactions = []; HistoricalDates = []; DateOfTransaction = datetime.datetime(1900,1,1).today(); def __init__(self, balance): self.balance = balance; def deposit(self, amt): self.balance = self.balance + amt t = Transaction("Deposit",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); print "Balance:" + str(self.balance); def withdraw(self,amt): self.balance = self.balance - amt t = Transaction("Withdraw",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.HistoricalDates.append(self.DateOfTransaction); self.transactions.append(t); print "Balance:" + str(self.balance); def displayTransactions(self): self.DateOfTransaction = datetime.datetime(1900,1,1).today(); t = Transaction("View transactions",self.balance); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); for key in self.transactions: key.showTransaction(); def viewRequests(self): print "Date of transaction" + " "+"Type of transaction" + " " +"Final balance"; for key in self.transactions: key.showRequest(); def getbalance(self): return self.balance foo = Account(10000) b = 1 print "Welcome to the Petty Cash System!" print "Primary account balance for an account:10000" while(b != 5): print "Please make a selection by typing one of the following options." print "1.Deposit balance #: 1" print"2.Withdraw balance #: 2" print "3.Show transactions #: 3" print "4.Show requests #: 4" print "5.exit the Database type the #: 5" b = input(':') if b == 1: print "Enter the Deposit:" n = raw_input(':') foo.deposit(int(n)); if b == 2: print "Enter the Withdraw:" n = raw_input(':') foo.withdraw(int(n)); if b == 3: foo.displayTransactions(); if b == 4: foo.viewRequests(); if b == 5: break; Question Details - 350 Karma Points For the petty cash program below, please add new capabilities. 1. Add further attributes to the Account class (account's name, belong to which department, responsible person's name, title, phone number, email address, etc) 2. Create a list of accounts. Let the user add new accounts to the list. 3. Ask the user for the name of an account and then print the account's details.
----------------------------
import shelve import string import datetime class Transaction: DateOfTransaction = datetime.datetime(1900,1,1).today(); TypeOfTransaction = ""; FinalBalance = ""; def __init__(self, TypeOfTransaction,FinalBalance): self.TypeOfTransaction =TypeOfTransaction; self.FinalBalance = FinalBalance; def showTransaction(self): if(self.TypeOfTransaction!="View transactions"): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); def showRequest(self): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); class Account: balance = 0.0; transactions = []; HistoricalDates = []; DateOfTransaction = datetime.datetime(1900,1,1).today(); def __init__(self, balance): self.balance = balance; def deposit(self, amt): self.balance = self.balance + amt t = Transaction("Deposit",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); print "Balance:" + str(self.balance); def withdraw(self,amt): self.balance = self.balance - amt t = Transaction("Withdraw",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.HistoricalDates.append(self.DateOfTransaction); self.transactions.append(t); print "Balance:" + str(self.balance); def displayTransactions(self): self.DateOfTransaction = datetime.datetime(1900,1,1).today(); t = Transaction("View transactions",self.balance); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); for key in self.transactions: key.showTransaction(); def viewRequests(self): print "Date of transaction" + " "+"Type of transaction" + " " +"Final balance"; for key in self.transactions: key.showRequest(); def getbalance(self): return self.balance foo = Account(10000) b = 1 print "Welcome to the Petty Cash System!" print "Primary account balance for an account:10000" while(b != 5): print "Please make a selection by typing one of the following options." print "1.Deposit balance #: 1" print"2.Withdraw balance #: 2" print "3.Show transactions #: 3" print "4.Show requests #: 4" print "5.exit the Database type the #: 5" b = input(':') if b == 1: print "Enter the Deposit:" n = raw_input(':') foo.deposit(int(n)); if b == 2: print "Enter the Withdraw:" n = raw_input(':') foo.withdraw(int(n)); if b == 3: foo.displayTransactions(); if b == 4: foo.viewRequests(); if b == 5: break; Question Details - 350 Karma Points For the petty cash program below, please add new capabilities. 1. Add further attributes to the Account class (account's name, belong to which department, responsible person's name, title, phone number, email address, etc) 2. Create a list of accounts. Let the user add new accounts to the list. 3. Ask the user for the name of an account and then print the account's details.
----------------------------
import shelve import string import datetime class Transaction: DateOfTransaction = datetime.datetime(1900,1,1).today(); TypeOfTransaction = ""; FinalBalance = ""; def __init__(self, TypeOfTransaction,FinalBalance): self.TypeOfTransaction =TypeOfTransaction; self.FinalBalance = FinalBalance; def showTransaction(self): if(self.TypeOfTransaction!="View transactions"): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); def showRequest(self): print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance); class Account: balance = 0.0; transactions = []; HistoricalDates = []; DateOfTransaction = datetime.datetime(1900,1,1).today(); def __init__(self, balance): self.balance = balance; def deposit(self, amt): self.balance = self.balance + amt t = Transaction("Deposit",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); print "Balance:" + str(self.balance); def withdraw(self,amt): self.balance = self.balance - amt t = Transaction("Withdraw",self.balance); self.DateOfTransaction = datetime.datetime(1900,1,1).today(); self.HistoricalDates.append(self.DateOfTransaction); self.transactions.append(t); print "Balance:" + str(self.balance); def displayTransactions(self): self.DateOfTransaction = datetime.datetime(1900,1,1).today(); t = Transaction("View transactions",self.balance); self.transactions.append(t); self.HistoricalDates.append(self.DateOfTransaction); for key in self.transactions: key.showTransaction(); def viewRequests(self): print "Date of transaction" + " "+"Type of transaction" + " " +"Final balance"; for key in self.transactions: key.showRequest(); def getbalance(self): return self.balance foo = Account(10000) b = 1 print "Welcome to the Petty Cash System!" print "Primary account balance for an account:10000" while(b != 5): print "Please make a selection by typing one of the following options." print "1.Deposit balance #: 1" print"2.Withdraw balance #: 2" print "3.Show transactions #: 3" print "4.Show requests #: 4" print "5.exit the Database type the #: 5" b = input(':') if b == 1: print "Enter the Deposit:" n = raw_input(':') foo.deposit(int(n)); if b == 2: print "Enter the Withdraw:" n = raw_input(':') foo.withdraw(int(n)); if b == 3: foo.displayTransactions(); if b == 4: foo.viewRequests(); if b == 5: break;
Explanation / Answer
import shelveimport string
import datetime
class Transaction:
DateOfTransaction = datetime.datetime(1900,1,1).today();
TypeOfTransaction = "";
FinalBalance = "";
def __init__(self, TypeOfTransaction,FinalBalance):
self.TypeOfTransaction =TypeOfTransaction;
self.FinalBalance = FinalBalance;
def showTransaction(self):
if(self.TypeOfTransaction!="View transactions"):
print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance);
def showRequest(self):
print str(self.DateOfTransaction) + " "+self.TypeOfTransaction + " " +str(self.FinalBalance);
class Account:
balance = 0.0;
transactions = [];
HistoricalDates = [];
accountName = "";
accountDepartment = "";
responsiblePersonName = "";
title = "";
phonenumber = "";
emailAddress = "";
DateOfTransaction = datetime.datetime(1900,1,1).today();
def __init__(self, balance):
self.balance = balance;
def deposit(self, amt,accountName ,accountDepartment ,responsiblePersonName ,title ,phonenumber ,emailAddress):
self.balance = self.balance + amt
this.accountName = accountName
this.accountDepartment = accountDepartment
this.responsiblePersonName = responsiblePersonName
this.title = title
this.phonenumber = phonenumber;
this.emailAddress = emailAddress;
t = Transaction("Deposit",self.balance);
self.DateOfTransaction = datetime.datetime(1900,1,1).today();
self.transactions.append(t);
self.HistoricalDates.append(self.DateOfTransaction);
print "Balance:" + str(self.balance);
def withdraw(self,amt):
self.balance = self.balance - amt
t = Transaction("Withdraw",self.balance);
self.DateOfTransaction = datetime.datetime(1900,1,1).today();
self.HistoricalDates.append(self.DateOfTransaction);
self.transactions.append(t);
print "Balance:" + str(self.balance);
def displayTransactions(self):
self.DateOfTransaction = datetime.datetime(1900,1,1).today();
t = Transaction("View transactions",self.balance);
self.transactions.append(t);
self.HistoricalDates.append(self.DateOfTransaction);
for key in self.transactions:
key.showTransaction();
def viewRequests(self):
print "Date of transaction" + " "+"Type of transaction" + " " +"Final balance";
for key in self.transactions:
key.showRequest();
def getbalance(self):
return self.balance
foo = []
b = 1
i=-1;
name=""
balance=0;
department =""
person =""
title =""
phone =""
email =""
print "Welcome to the Petty Cash System!"
print "Primary account balance for an account:10000"
while(b != 5):
i=-1;
print "Please make a selection by typing one of the following options."
print "1.Add Account #1"
print "2.Deposit balance #: 2"
print "3.Withdraw balance #: 3"
print "4.Show transactions #: 4"
print "5.Show requests #: 5"
print "6.exit the Database type the #: 6"
b = input(':')
if b == 1:
print "Enter the Account Name:"
name = raw_input(':')
print "Enter the Account Balance:"
balance = int(raw_input(':'))
print "Enter the Account Department:"
department = raw_input(':')
print "Enter the Account Responsible person:"
person = raw_input(':')
print "Enter the Account Title:"
title = raw_input(':');
print "Enter the Phone number:"
phone = raw_input(':');
print "Enter the Email:"
email = raw_input(':');
foo.append(Account(balance ,name,department ,person ,title ,phone ,email ))
print "Successfully added"
if b == 2:
print "Enter the Deposit:"
n = raw_input(':')
print "Enter the Account name:"
name = raw_input(':')
for key in foo:
i = i+1;
if key.accountName == name:
foo[i].deposit(int(n));
if b == 3:
print "Enter the Withdraw:"
n = raw_input(':')
print "Enter the Account name:"
name = raw_input(':')
for key in foo:
i = i+1;
if key.accountName == name:
foo[i].withdraw(int(n));
if b == 4:
print "Enter the Account name:"
name = raw_input(':')
for key in foo:
i = i+1;
if key.accountName == name:
foo[i].displayTransactions();
if b == 5:
print "Enter the Account name:"
name = raw_input(':')
for key in foo:
i = i+1;
if key.accountName == name:
foo[i].viewRequests();
if b == 6:
break;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.