[Tutor] Need Help

Michael P. Reilly arcege at gmail.com
Wed Jul 12 00:34:29 CEST 2006


On 7/10/06, Shappell, John J CW2 <john.j.shappelljr at us.army.mil> wrote:
>
>  Here is the assignment
>
>    1. 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.
>
> This is where I am at so far.  I don't understand how to get the Account
> class into the program. Can you help a little,  Just looking for an idea or
> some guidance
>
> #!/usr/bin/python
> # Filename: petty cash.py
>
> print "Welcome to the petty cash account"
> print "Did you deposit or withdrawl money today"
> print
>
> # print out menu
> print "please select a number"
> print "1 for deposit"
> print "2 for withdrawl"
>
> # Get user's choice:
> number = input (">")
> #
> if number == 1:
>     deposit = input ("how much?")
>     print "I deposited:", deposit
>
> elif number == 2:
>     withdrawl = input ("How Much?")
>     print "I withdrew:", withdrawl
>
> print "what is today's date?"
> # Get date from user
> date = input (">")
>
> *This is where I get stuck. The program will allow me to input the deposit
> or withdrawl ammount and the date but does nothing ownce it gets here*
>
> 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
>
John,
  Another aspect of your assignment will be to be able to use this
functionality from the "command-line".  This means: without asking questions
from the user, but input is being passed as arguments.  You will eventually
have to think how this will affect the structure of your program.
  -Arcege
-- 
There's so many different worlds,
So many different suns.
And we have just one world,
But we live in different ones.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060711/41929b17/attachment.htm 


More information about the Tutor mailing list