def new_account():
    acc = validator.text_to_array(account_file)
    Acc_name = validator.validate_user_input("enter your account name", str, "please enter  a valid name")
    Acc_number = validator.acc_no_generator(account_file)
    print "this is your account number {}".format(Acc_number)
    Acc_bal = validator.validate_user_input("enter your initial bal", int, "please enter  valid amount")
    new_acc = BankAccount(Acc_name,Acc_number,Acc_bal )
    user_acc = new_acc.save_acc()
    acc.append(user_acc)
    validator.account_writer(account_file, '{}'.format(acc))
    return user_acc
Beispiel #2
0
def open_account():
    name = input('What is your full name? ')
    date = input('What is the date? ')
    account_number = int(input('What is the account number? '))
    starting_balance = int(input('What is the starting amount? '))
    newAccount = BankAccount(name, date, account_number, starting_balance)
    Accounts[account_number] = newAccount
def deposit_amount():
    while True:
        acc_no = validator.validate_user_input("enter your account No", int, "please enter  valid account")
        user_acc = validator.get_acc(account_file, acc_no)
        if user_acc == False:
            print "user with that this {} number found".format(acc_no)
        else:
            break
    amount = validator.validate_user_input("enter amount to deposit", int, "please enter  valid amount")
    acc = validator.text_to_array(account_file)
    user = BankAccount(user_acc['name'],user_acc['account_no'],user_acc['balance'] )
    deposit = user.deposit(amount)
    acc.append(deposit)
    validator.account_writer(account_file, '{}'.format(acc))
    print 'successful'
    return user_acc, deposit
def withdraw_amount():
    while True:
        acc_no = validator.validate_user_input("enter your account No", int, "please enter  valid account")
        user_acc = validator.get_acc(account_file, acc_no)
        if user_acc == False:
            print "user with that this {} number found".format(acc_no)
        else:
            break
    acc = validator.text_to_array(account_file)
    user = BankAccount(user_acc['name'],user_acc['account_no'],user_acc['balance'] )
    while True:
        amount = validator.validate_user_input("enter to withdraw", int, "please enter  valid amount")
        withdrawer = user.withdraw(amount)
        if withdrawer  == False:
            print "You acc balance is {} you cannot withdraw {}".format(user.balance, user.acc['balance'], u)
        else:
            break
    acc.append(withdrawer)
    validator.account_writer(account_file, '{}'.format(acc))
    return  user_acc, withdrawer
Beispiel #5
0
def app3(): #defines app3
    print("Welcome to App3") #prints intro to app3
    print("===============")
    print( )
    mortgage, rate, monthly = input("Enter amount to borrow, rate, and monthly payment: ").split() #takes user inputs and assigns them to correct variables
    mortgage, rate, monthly = float(mortgage), float(rate), float(monthly) #changes inputs to numbers to be acted on
    mortgageacc = BankAccount("Mortgage", mortgage, rate)#initializes mortgage account of class BankAccount
    print(mortgageacc) #prints balance of mortgage acount
    running = True #initializes varibales tto be used in loops
    month = 1
    year = 0
    while running==True: #while loop 
        if mortgageacc.balance>0: #if the balance of mortgage account is greateer than 0
            if month==1:  #if statement for first month of loop
                mortgageacc.withdraw(monthly-(mortgageacc.rate/12)*mortgageacc.balance) #withdraws amount from motgage account
                initprincipal = mortgage-mortgageacc.balance #defines initial principal variable
                initinterest = monthly-initprincipal #defines initial interest variable
                mort = open("Amortization.txt", "w") #creates new file Amortizaion.txt for wrtiting
                mort.write("Month--Principal paid--Interest paid") #writes in new file the correct format for the rest of the writing process
                mort.write("\n") #skips line in new file
                mort.write(str(month)) #writes the month
                mort.write("--")
                mort.write(str(initprincipal)) #writes the principal paid
                mort.write("--")
                mort.write(str(initinterest)) #writes the interst paid
                mort.close() #closes file opened earlier
                month += 1 #adds 1 to month variable
            else: #for rest of months in loop
                mortgageacc.withdraw(monthly-(mortgageacc.rate/12)*mortgageacc.balance) #withdraws amount from mortgage account
                principal = (mortgage-mortgageacc.balance) #initializes new principle tobe paid
                interest = (month*monthly)-principal #initializes new interest to be paid
                mort = open("Amortization.txt", "a") #opens file again for appending
                mort.write("\n")
                mort.write(str(month)) #writes the month
                mort.write("--")
                mort.write(str(principal))#writes principal paid
                mort.write("--")
                mort.write(str(interest)) #writes interest paid
                mort.close() #closes file
                month += 1 #adds 1 to month
                if (month % 12 == 0): #checks if a year has passed by using remainder of month divided by 12
                    year += 1 #adds 1 to year
        else:
            month -= 1 #gets rid of extra month added in loop
            running = False #stops loop
    print("You will be paying your loan after ", month, " month! (or ", float(year), " years!)") #prints how long it will take to pay off loan
    total = month*monthly #gets total paid by user
    print("You borrowed $%s but paid $%s in total (with interests)"%(mortgage,total)) #prints totals
Beispiel #6
0
from Bank import BankAccount

print("Welcome to App1\n===============\n")
salary, initial_cbalance, initial_sbalance = map(
    float,
    input(
        "Enter salary and initial balances for Checking and Saving accounts: "
    ).split())
#create accounts
acc1 = BankAccount("Checking", initial_cbalance)
acc2 = BankAccount("Saving", initial_sbalance)

print(acc1)
print(acc2)
print("Month--salary--expense--saving")


def transfer(amount, source, destination):
    source.withdraw(amount)
    destination.deposit(amount)


for i in range(12):
    expense = .8 * salary
    addsaving = .15 * salary
    print(i + 1,
          "--" + str(int(salary)) + "--" + str(int(expense)) + "--" +
          str(int(addsaving)),
          sep='')
    #deposit the money made into checking
    acc1.deposit(salary)
Beispiel #7
0
from Bank import BankAccount

print("Welcome to App3\n===============\n")
#ask for how much is being borrowed, the rate, and the monthly payment
initial_borrow, rate, monthly_payment = map(float, input("Enter amount to borrow, rate, and monthly payment: ").split())
#create the account
mortgage = BankAccount("Mortgage",initial_borrow)
print(mortgage)
#create amortization file
f1 = open("Amortization.txt","w")
f1.write("Month--Principal paid--Interest paid")
f1.close()

#initialize the counter
counter = 0
principal = 0
interest_paid = 0
mortgage.b = initial_borrow

while mortgage.b > 0:
    amount = monthly_payment - (rate/12) * mortgage.b
    mortgage.withdraw(amount)
    #increase principal paid and interest paid for each month
    principal = principal + amount
    interest_paid = (monthly_payment - amount) + interest_paid
    #increase counter
    counter = counter + 1
    f1 = open("Amortization.txt","a")
    f1.write("\n"+str(counter)+"--"+str(principal)+"--"+str(interest_paid))
    f1.close()
    
Beispiel #8
0
from Student import Student
from Bank import BankAccount

# alice = Person("Alice","Alicson",28)
alice = Student("Alice", "Alicson", 28, "1234", 3.9)
alice_account = BankAccount(alice)
alice_account.credit(1000)
print(alice_account)

print(alice_account.debit(500))
print(alice_account)

print(alice_account.debit(600))
print(alice_account)
Beispiel #9
0
def app1():  #defines function of app1
    print("Welcome to App1")  #prints intro to app1
    print("===============")
    print()
    salary, checking, saving = input(
        "Enter salary and initial balances for Checking and Saving accounts: "
    ).split(
    )  #records multiple inputs by user and splits them into variables listed
    salary, checking, saving = float(salary), float(checking), float(
        saving
    )  #floats inputs (which are strings) from user so they can be used in math equations
    checkingacc = BankAccount(
        "Checking",
        checking)  #initializes checking account of class BankAccount
    savingacc = BankAccount(
        "Saving", saving)  #initializes saving account of class BankAccount
    print(checkingacc)  #displays current balance of checking account
    print(savingacc)  #displays current balance of saving account
    print("Month--salary--expense--saving"
          )  #shows user the format for the display
    for i in range(12):  #loop for 12 months
        if i == 0:  #if statement for firat month in loop
            print(i + 1, "--", int(salary), "--", int(salary * .8), "--",
                  int(salary * .15))  #prints numbers in correct format
            checkingacc.deposit(salary *
                                .05)  #deposits money into the checking account
            savingacc.deposit(salary *
                              .15)  #deposits amount into saving account
        else:  #for rest of months in loop
            salary += salary * .002  #adds salary raise to the salary
            print(i + 1, "--", int(salary), "--", int(salary * .8), "--",
                  int(salary * .15))
            checkingacc.deposit(salary * .05)
            savingacc.deposit(salary * .15)
    print(checkingacc)  #prints new balance of checking account
    print(savingacc)  #prints new balance of saving account
Beispiel #10
0
def app2():
    print("Welcome to App2") #prints intro to app2
    print("===============")
    print( )
    saving, rate = input("Enter initial balance and interest rate for saving account: ").split() #assigns multiple inputs from user inputs to corresponding variables
    saving, rate = float(saving), float(rate) #floats inputs from user
    savingacc = BankAccount("Saving", saving, rate) #initializes object of class BankAccount called saving account
    print(savingacc) #prints balance of saving account
    print( )
    print("How many years will it take to triple my balance?")
    stop = savingacc.balance*3 #variable for telling loop when to stop
    year = 0 #variable for number of years until a certain goal is reached
    running = True #variable for while loop
    while running==True: #loop until variable running is set to false
        if savingacc.balance<stop: #if the balance is less than tripled
            newbalance = savingacc.addcompound() #addcompound function is called to add balance of account
            savingacc.deposit(newbalance-savingacc.balance) #amount is deposited into saving account
            year += 1 #year is raised by 1
        else:
            running = False #stops while loop
    print("You will triple your initial balance after ", year, "Years!") 
    print(savingacc)
    print( )
    print("Would this be better if I keep contributing 5% of my initial amount every year?")
    savingacc = BankAccount("Saving", saving, rate) #re-initializes saving account data object
    running = True
    year = 0
    fivepercent = savingacc.balance*.05 #variable for five perecent of balance
    while running==True:
        if savingacc.balance<stop:
            newbalance = savingacc.addcompound()
            savingacc.deposit(newbalance-savingacc.balance)
            savingacc.deposit(fivepercent) #also deposits five percent of initial balance
            year += 1
        else:
            running = False
    print("You will triple your initial balance after ", year, "Years!")
    print(savingacc)
    print( )
    print("Would this be even better if in addition my interest rate grows up by 0.5% every year?")
    savingacc = BankAccount("Saving", saving, rate) #once again re-initializes the variables
    running = True
    year = 0
    while running==True:
        if savingacc.balance<stop:
            if year!=0: #if statement for first year of loop
                savingacc.rate += savingacc.rate*.005
            newbalance = savingacc.addcompound()
            savingacc.deposit(newbalance-savingacc.balance)
            savingacc.deposit(fivepercent)
            year += 1
        else:
            running = False
    print("You will triple your initial balance after ", year, "Years!")
    print(savingacc)