Question

Python: Simple Banking Application Project Solution: • Input file: The program starts with reading in all...

Python: Simple Banking Application

Project Solution: • Input file: The program starts with reading in all user information from a given input file. The input file contains information of a user in following order: username, first name, last name, password, account number and account balance. Information is separated with ‘|’. o username is a unique information, so no two users will have same username. Sample input file: Username eaglebank has password 123456, account number of BB12 and balance of $1000.

Program flows as below:

1) data is read in from the given input file,

2) it will be saved to a dictionary referred as users where each key is username and the value will be a list containing rest of the information: first name, last name, password, account number and account balance. One example of key-value pair is: 'eaglebank': ['Eagle', 'Bank', '123456', 'BB12', 1000.0]. 3) user will be presented with a menu and all the operations related to menu options will be performed on this users dictionary.

Main Menu: The program starts with a welcome message and displays main menu. Main menu contains following different options for a user:

Main Menu

1. New User

2. Sign In

3. Exit Application

(Option 1) New User: User has the option of creating a new account. Creating a new account implies adding a new key-value pair in users dictionary. Once account creation is successful, the program will display some informational message and will take user to the Main Menu for relogin. If user chooses a username that already exists, program will ask for another username until user inputs a different username. Hint: A while loop will help you to accomplish this repetition if user chooses an existing username. This scenario is very similar to any login system like mason username. Each user has a unique username. A sample interface can be as follows:

Outcome- 1 (no error)

New user

Enter first name: Jane

Enter last name: Doe

Enter your username: jdoe

Enter your password (between 6-12 characters): 1234567

Your random account number is JKBB

Enter initial balance to deposit: 89

Account jdoe added.

Please login again to start banking.

Outcome - 2 (with error – username already taken)

New user Enter first name: James

Enter last name: Madison

Enter your username: eaglebank

Username already taken. Please choose another username.

Enter your username: hawk

Username already taken. Please choose another username

Enter your username: jcon

Enter your password (between 6-12 characters): password

Your random account number is INRD

Enter initial balance to deposit: 1000

Account jcon added.

Please login again to start banking

(Option 2) Sign In: Existing users need to sign in to account using username and password. Once username and password matches, program will take user to existing user menu (see sub-options below for details). Each user has maximum three chances to login, once all the chances are used, program will display a message and take back to main menu.

Output - 1 (no error)

Enter username: eaglebank

Enter password: 123456

Login successful. Welcome eaglebank

Existing User Menu

1. Deposit

2. Withdraw

3. Fast Cash

4. Transfer

5. Account Summary

6. Logout Enter option (1-6):

Output- 2 (users try to login three times)

Enter option (1-3): 2

Enter username: eaglebank

Enter password: 45678910

Username and password do not match.

Enter username: eaglebank

Enter password: password

Username and password do not match.

Enter username: eaglebank

Enter password: 1234567!!

Username and password do not match. You tried to login three times. Taking to main menu.

Homework Answers

Answer #1

CODE -

import string

import random

alphanumeric = string.ascii_uppercase + string.digits

acc_dict={}

account = open("bank.txt")

acc_list = [x.strip("\n").split("|") for x in account.readlines()]

for i in range(len(acc_list)):

    acc_list[i][-1]=float(acc_list[i][-1])

    acc_dict[acc_list[i][0]] = acc_list[i][1:]


print("\n*****WELCOME TO VISION BANKING APPLICATION*****\n")

while 1:

    print("Main Menu \n1. New User \n2. Sign In \n3. Exit Application \n")

    n=int(input("Enter your choice: "))

    if n==1:

        fname = input("Enter first name: ")

        lname = input("Enter last name: ")

        username = input("Enter your username: ")

        while username in acc_dict:

            print("Username already taken. Please choose another username.")

            username = input("Enter your username: ")

        password = input("Enter your password (between 6-12 characters): ")

        while len(password)<6 or len(password)>12:

            print("Password length should be between 6-12 characters.")

            password = input("Enter your password (between 6-12 characters): ")

        acc_no = ''.join((random.choice(alphanumeric) for i in range(4)))

        print("Your random account number is",acc_no)

        bal = float(input("Enter initial balance to deposit: "))

        new_acc=[fname,lname,password,acc_no,bal]

        acc_dict[username] = new_acc

        print("Account",username,"added.")

        print("Please login again to start banking.")

        continue

    elif n==2:

        count = 0

        flag = 0

        username = input("Enter username: ")

        password = input("Enter password: ")

        while username not in acc_dict or acc_dict[username][2] != password:

            print("Username and password do not match.")

            count +=1

            if count==3:

                print("You tried to login three times. Taking to main menu.")

                flag = 1

                break

            username = input("Enter username: ")

            password = input("Enter password: ")

        if flag ==1:

            continue

        else:

            print("Login successful. Welcome",username)

            print("Existing User Menu")

            while 1:

                print("1. Deposit \n2. Withdraw \n3. Fast Cash \n4. Transfer \n5. Account Summary \n6. Logout")

                choice = int(input("Enter option (1-6)"))

                if choice==1:

                    amt = float(input("Enter amount to deposit: "))

                    acc_dict[username][4] +=amt

                    print("Deposit Successful")

                    continue

                elif choice==2:

                    flag=0

                    amt = float(input("Enter amount to withdraw: "))

                    if acc_dict[username][4]<amt:

                        print("Insufficient Funds in your account!")

                        flag = 1

                        break

                    if flag==1:

                        continue

                    acc_dict[username][4] -=amt

                    print("Withdrawal Successful")

                    continue

                elif choice==3:

                    flag=0

                    print("1. 500 \n2. 1000 \n3. 5000")

                    x = int(input("Choose amount to withdraw: "))

                    if x==1:

                        if acc_dict[username][4]<500:

                            print("Insufficient Funds in your account!")

                            flag = 1

                            break

                        if flag==1:

                            continue

                        acc_dict[username][4] -=500

                        print("Withdrawal Successful")

                        continue

                    elif x==2:

                        if acc_dict[username][4]<1000:

                            print("Insufficient Funds in your account!")

                            flag = 1

                            break

                        if flag==1:

                            continue

                        acc_dict[username][4] -=1000

                        print("Withdrawal Successful")

                        continue

                    elif x==3:

                        if acc_dict[username][4]<5000:

                            print("Insufficient Funds in your account!")

                            flag = 1

                            break

                        if flag==1:

                            continue

                        acc_dict[username][4] -=5000

                        print("Withdrawal Successful")

                        continue

                    else:

                        print("Invalid input")

                        continue

                elif choice==4:

                    user = input("Enter the username of user you want to transfer money: ")

                    if user not in acc_dict:

                        print("User does not exist")

                        continue

                    amt=float(input("Enter amount you want to transfer: "))

                    if acc_dict[username][4]<amt:

                        print("Insufficient Funds in your account!")

                        flag = 1

                        break

                    if flag==1:

                        continue

                    acc_dict[username][4] -=amt

                    acc_dict[user][4]+-amt

                    print("Transfer Successful")

                    continue

                elif choice==5:

                    print("***Account Summary***")

                    print("First Name: ",acc_dict[username][0])

                    print("Last Name: ",acc_dict[username][1])

                    print("Username: ",username)

                    print("Account Number: ",acc_dict[username][3])

                    print("Account Balance: ",acc_dict[username][4])

                elif choice==6:

                    break

                else:

                    print("Invalid Choice!")

    elif n==3:

        exit(0)

    else:

        print("Invalid Choice!")

SCREENSHOTS -

CODE -

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using Java: implement a program with the following features. Thanks Produce a menu for the user...
Using Java: implement a program with the following features. Thanks Produce a menu for the user with 3 choices. Add a new user Attempt login See all users If the user chooses #1, prompt them for a username (a string). Then a password (a string). Using SHA-2 hash the password they gave you, and store the resulting username and hashed password in a datastructure of your choice. (It can be 2 arrays, one for usernames, one for hashed passwords). If...
For this assignment, create an html page that has a login form. The form should have...
For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. This should have a type text for the user to enter UserName 2. This should have a type password (like text except cannot see the text that is typed in), for the user to enter password. 3. Submit button (type submit, as we did in class on 2/6). The form method should be set to POST and the action...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts,...
For this assignment, you will be creating a simple “Magic Number” program. When your program starts, it will present a welcome screen. You will ask the user for their first name and what class they are using the program for (remember that this is a string that has spaces in it), then you will print the following message: NAME, welcome to your Magic Number program. I hope it helps you with your CSCI 1410 class! Note that "NAME" and "CSCI...
Write regular expressions that will match IP addresses and usernames in a Microsoft IIS log file....
Write regular expressions that will match IP addresses and usernames in a Microsoft IIS log file. First, you will write a regular expression that matches IP addresses within the re.compile function call on line 36. Next, you will write a regular expression that matches usernames (in the format domain\username) on line 50. Finally, in steps 3 and 4 you will write a loop for each step that displays all the IP addresses (gathered into the list ipAddresses) and usernames (gathered...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies...
Finish the CustomerAccountTransactions program that reads customer accounts receivable data from a file and then applies a series of transactions to the accounts. Its main() method uses the CustomerAccounts class to manage a collection of CustomerAccount objects: reading customer accounts data & transactions, and obtaining a String showing the customer accounts data after the operations are complete. You will need to complete the readCustomerAccounts () and applyTransactions() methods in the CustomerAccounts class. First, please fill in your name in the...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if...
<?php    if(isset($_GET['submit'])){ //sanitize the input        /* Check the error from the input: if input from user is empty -> get an error string variable if input is not empty -> use preg_match() to match the pattern $pattern = "/^[1-9][0-9]{2}(\.|\-)[0-9]{3}(\.|\-)[0-9]{4}$/"; -> if it's a matched, get a success string variable */           } ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link...
Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of...
Create a flowgorithm program to calculate the Area of Circle first then do the Circumference of Circle. The user will have the ability to convert Area OR the Circumference. That means we need to add a decision structure to the program. Furthermore, they need to be able to do it as many times as they want. That means we need to add a main loop structure to the program. The user will also have the choice of whether to run...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT