ok so heres the thing, ive got to to do this program for college but the lecturer is a numpty and wont help anyone. so im stuck. ive only got so far into the program and cant get the most important bit to work where it is supposed to.

its a python code for an atm machine program, and needs a pin number to be read in and verified, then a menu to show a withdraw with statement and a with draw without statement, within these 2 have to be the option to select either £50, £100, £150,£200. ive only got the following code if anyone can help point me in the right direction it would be a great help.
many thanks craig

import os
import time

# pin validation
def pin():
print "welcome to the Bellco Atm"
print "========================="
print "please enter your card into the slot provided"
print "============================================="
print "card accepted, awaiting pin"
print "==========================="
print "please enter you pin"
print "===================="

def withdrawal_with_statement():
print "please enter the amount you wish to withdraw"
print "1 50"
print "2 100"
print "3 150"
print "4 200"
print "5 exit menu"


#print greeting
print
print "welcome to the bell co banking program"
print "======================================"
print
def check_pin(pin):
"""check if pin number pin is between 1000 and 9000"""
if 1000 <= pin <= 9000:
return True
return False
pin = input("Enter pin number (between 1000 and 9000): ")
print check_pin(pin)

#define menu
print
while True:
# print out the menu
print "please select an option :"
print "1 withdrawal with statement"
print "2 withdrawal without statement"
print "3 statement only"
print "x exit"

# get the user's choice:
choice = raw_input("> ")
# carry out task:
if choice == '1':
withdrawal_with_statement()
elif choice == '2':
withdrawal_without_statement()
elif choice == '3':
statement_only()
elif choice == 'x':
print "thank you for using this program"
break
else:
print "invalid choice"
print

Hi muddpigeon,

So I have some questions about your code:

(1) I don't know what 'withdraw with' and withdraw without' mean ...
(2) It looks like you want the code to execute sequentially from top to bottom. Is that correct? If so, I have a suggestion about organization. If not, what is your overall plan ('pseudo-code') for your atm machine?
(3) How does the machine know what the correct pin # is? Will any pin between 1000 and 9000 do the trick?

Also, when you post code, use the [ code=Python ] and [ /code ] tags (eliminate the spaces for proper functioning) so that your code will have the proper indentation levels.

Jeff

hi jeff,
ok the withdraw with and withdraw without are funstions for withdrawing money from the atm with or without a statement, i dont have the pseudo code to hand unfortunatley as it is in college, and the program does flow sequentially.

any other advice will be a great help.

many thanks

muddpigeon.

OK, the pseudo-code is actually something you create before you start, and it guides your thinking. Here's the coding process I follow for non-class-based programs:

(1) Decide on the functionality of the program. This is called the Use Case or User Story.

(2) Divide up the functionality into small pieces. These will be your functions.

(3) Write a function at a time, testing as you go.

Now, I would recommend for maximum learning purposes that you pause here and do steps 1-2, if you've not already done so.

OK, that's done.

Now, it looks like your overall program organization wants to be something like this:

print greeting
print directions
get pin
if pin is valid:
    while eternity lasts:
        get user choice
        if choice == withdraw_with:
            get amount
            spit out cash
            print statement
       elif choice == withdraw_without:
            get amount
            spit out cash
       elif choice == x
            quit program
       else:
            print error

Is that your basic plan?

Now, each pseudo-code statement, such as "print greeting" or "get pin", becomes a separate function.

These functions do not get executed in order from top to bottom. Instead, they get defined at the beginning of your program, and then the main code -- above -- will call them as needed.

Does that help you get started?
Jeff

Hi..
do u have a sample program that like the one u show but in java language..??
Hit me back ..plss

if u have any..thnx

Post over in the Java forum, I guess.

But I kinda liked my pseudo-code in post #3, so maybe that can get you somewhere.

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.