Answer to Question #306363 in Python for Eren

Question #306363

ABC Banking maintains a record of their clients accounts in a text file named "custBalances.txt" using the following format:


accNo,Lastname,Firstname,PIN,balance


ABC clients would like to have a means to know their balances conveniently.


Your task is to write a program that will access the data of the customer from the text file by supplying their account number and PIN code. Given a valid account number and PIN, program must display the customer information.


Your program must use the following function in a separate python file

  • getInput function which will ask for the account number and PIN of the customer. Function must validate account No and PIN.
  • viewCustomerInfo function which will return the customer Info .


Input


1. data

Output


Enter·account·number:·356662421
Account·does·not·exist.
Enter·account·number:·356662420
Enter·PIN:·1676
Account·No.:·356662420
Customer·Name:·Branden·Rivers
Balance:·PHP·49,316.00

Enter·account·number:·X
Good·Bye!

Enter·account·number:·X
Good·Bye!




1
Expert's answer
2022-03-05T07:48:11-0500
def CheckBal(A,B):
    t = int(input("Enter the Account No. to check balance : "))
    F=0
    for r in range(0,len(A)):
        if(t == A[r]):
           F=1
           print("Account No. %d, Bal. = %d"%(A[r],B[r]))
    if(F==0):
        print("Account No (%d) Not Found"%t)
    
   
MinAccountNo=999
MaxAccountNo=9999
MinAccountBal=1
MaxAccountBal=100000


ID = 50506
s=str(ID)
temp=[]
for r in range(0,len(s)):
    temp.append(ord(s[r]))
N=max(temp)-0x30
AccountNo = []
Bal = []
for r in range(0,N):
    AccountNo.append(999+r)
    Bal.append(123+r*2)
    
print("No.of accounts (N) = %d"%N)


for r in range(0,N):
    while(AccountNo[r]<MinAccountNo or AccountNo[r]>MaxAccountNo):
        s = "Enter the Account Number (" + str(MinAccountNo) + " to " + str(MaxAccountNo) + "): "
        AccountNo[r] = int(input(s))
    while(Bal[r]<MinAccountBal or Bal[r]>MaxAccountBal): 
        s = "Enter the Balance (" + str(MinAccountBal) + " to " + str(MaxAccountBal) + "): "
        Bal[r] = int(input(s))
Min=Bal[0]
MinInd=0
Max=Bal[0]
MaxInd=0


for r in range(0,N):
    if(Min>=Bal[r]):
        Min = Bal[r]
        MinInd=r
    if(Max<=Bal[r]):
        Max = Bal[r]
        MaxInd=r


Flag=1
while(Flag):
    print("\nPress 1 to Check Balance")
    print("Press 2 to Check Min. Balance Acount")
    print("Press 3 to Check Max. Balance Acount")
    print("Press 0 to QUIT")
    Flag=4
    while(Flag<0 or Flag>3):
        Flag = int(input("Enter Option (0 to 3): "))
    if(Flag==1): CheckBal(AccountNo,Bal)
    if(Flag==2): print("\nAccount No. with Min. Balance: Account No. %d,\tBal. = %d"%(AccountNo[MinInd],Bal[MinInd]))
    if(Flag==3): print("\nAccount No. with Max. Balance: Account No. %d,\tBal. = %d"%(AccountNo[MinInd],Bal[MinInd]))
    if(Flag==0): Flag=0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS