Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Petty Cash System You\'ve been given an assignment by your supervisor to program

ID: 3619838 • Letter: P

Question

Petty Cash System

You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the office for incidental purchases). The requirements for the program are to allow users to input the amount of cash deposited, the amount of cash withdrawn and to get a report of the balance at any given time. You will need to also add the date of each deposit and the date of each withdrawal and provide a date with the balance returned upon a given query. The program should be able to provide a printed report and support a command line query.

You are to use the object oriented properties of Python to accomplish this task.

Here are some hints to get you started:

First, define a class. The example below is just an example that defines a class named Account, you will need to enhance it to make it more realistic.
class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,amt):
self.balance = self.balance - amt
def getbalance(self):
return self.balance

Using a, the sample class above:
a = Account(1000.00)
a.deposit(550.23)
a.deposit(100)
a.withdraw(50)
print a.getbalance()

Write the a program to accomplish the above requirements. Of course you will need to add the features to accept input, print output, and so on as indicated. Run and debug the program.

Explanation / Answer

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):
                print str(self.DateOfTransaction) + "    "+self.TypeOfTransaction + "         " +str(self.FinalBalance);

class Account:
        balance = 0.0;
        transactions = [];
        def __init__(self, balance):
                self.balance = balance;
        def deposit(self, amt):
                self.balance = self.balance + amt
                t = Transaction("Deposit",self.balance);
                self.transactions.append(t);
                print "Balance:" + str(self.balance);
        def withdraw(self,amt):
                self.balance = self.balance - amt
                t = Transaction("Withdraw",self.balance);
                self.transactions.append(t);
                print "Balance:" + str(self.balance);
        def displayTransactions(self):
                for key in self.transactions:
                        key.showTransaction();
        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 != 3):
   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.exit the Database type the #: 4"
   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:
       break;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote