Hello! I am doing a final project for my CS119 class and for some reason my code
Fantastic news! We've Found the answer you've been seeking!
Question:
Hello! I am doing a final project for my CS119 class and for some reason my code only accept the third user from the stored file which is Steve and denied Mike and Jane. What is the reason and what is the right way to fix this issue? This code is in python and it would help a lot if you can provide screenshot of your answer since it's easier for me to understand. Thank you so much! Here is my code!
I have store the file in this format
Mike sorat1237# 350
Jane para432@4 400
Steve asora8731% 500
Transcribed Image Text:
def userInfo(file_name): usernames = [] passwords = [] balances = [] with open(file_name, 'r') as file: lines file. readlines() for line in lines [2:]: username, password, balance = line.strip().split() usernames.append(username) passwords.append(password) balances.append(float (balance)) return usernames, passwords, balances def printUserInfo(file_name, usernames, passwords, balances): with open(file_name, 'w') as file: file.write('Username Password Balance ') file.write(' ============== ') for i in range(len(usernames)): file.write(f'{usernames [i]) (passwords [i]] (balances [i]) ') def deposit (balance, amount): balance + amount return balance def withdraw(balance, amount): if balance >= amount: else: balance = amount print("Oh no! You have insufficient balance!") return balance def display (balance): print("Hello! Your current balance is", balance) def newUser(usernames, passwords, balances): username = input("What is your username?") password input ("What is your password?") amountB = float(input("What is your balance?")) usernames.append(username) passwords.append(password) balances.append(amountB) print("You have successfully added a new user!") def changeUser(usernames): username = input("What is your username?") if username in usernames: else: print("You have changed to", username) return username print(username, "is not found in our system!") file name="UserInformation.txt" usernames, passwords, balances = userInfo(file_name) current_user = "' while True: print("Hello! This is BankApp!") username = input("What is your username?") password=input ("What is your password?") if username in usernames and password == passwords [usernames. index (username)]: current_user = username print("Welcome to BankApp", current_user) break else: print("Oh no! It seems like you are not in our system! Please retry") while True: print("Type D to deposit money") print("Type W to withdraw money") print("Type B to display balance"). print("Type C to change user") print("Type A to add new user") print("Type E to exit") choice = input("What do you want to do?") if choice == "D": amount = float(input("How much do you want to deposit?")) balances [usernames.index (current_user)] = deposit (balances [usernames. index (current_user)], amount) display (balances [usernames. index (current_user)]) elif choice == "W": display (balances [usernames. index (current_user)]) amount = float (input("How much do you want to withdraw?")) balances [usernames. index (current_user)] = withdraw(balances [usernames. index (current_user)], amount) display (balances [usernames. index (current_user)]) elif choice == "B": display (balances [usernames. index (current_user)]) elif choice == "C": current_user = changeUser(usernames) elif choice == "A": newUser(usernames, passwords, balances) elif choice == "E": printUserInfo(file_name, usernames, passwords, balances) print("Thank you for using BankApp! Hope you have a nice day!") else: break print("Invalid option! Please try again.") def userInfo(file_name): usernames = [] passwords = [] balances = [] with open(file_name, 'r') as file: lines file. readlines() for line in lines [2:]: username, password, balance = line.strip().split() usernames.append(username) passwords.append(password) balances.append(float (balance)) return usernames, passwords, balances def printUserInfo(file_name, usernames, passwords, balances): with open(file_name, 'w') as file: file.write('Username Password Balance ') file.write(' ============== ') for i in range(len(usernames)): file.write(f'{usernames [i]) (passwords [i]] (balances [i]) ') def deposit (balance, amount): balance + amount return balance def withdraw(balance, amount): if balance >= amount: else: balance = amount print("Oh no! You have insufficient balance!") return balance def display (balance): print("Hello! Your current balance is", balance) def newUser(usernames, passwords, balances): username = input("What is your username?") password input ("What is your password?") amountB = float(input("What is your balance?")) usernames.append(username) passwords.append(password) balances.append(amountB) print("You have successfully added a new user!") def changeUser(usernames): username = input("What is your username?") if username in usernames: else: print("You have changed to", username) return username print(username, "is not found in our system!") file name="UserInformation.txt" usernames, passwords, balances = userInfo(file_name) current_user = "' while True: print("Hello! This is BankApp!") username = input("What is your username?") password=input ("What is your password?") if username in usernames and password == passwords [usernames. index (username)]: current_user = username print("Welcome to BankApp", current_user) break else: print("Oh no! It seems like you are not in our system! Please retry") while True: print("Type D to deposit money") print("Type W to withdraw money") print("Type B to display balance"). print("Type C to change user") print("Type A to add new user") print("Type E to exit") choice = input("What do you want to do?") if choice == "D": amount = float(input("How much do you want to deposit?")) balances [usernames.index (current_user)] = deposit (balances [usernames. index (current_user)], amount) display (balances [usernames. index (current_user)]) elif choice == "W": display (balances [usernames. index (current_user)]) amount = float (input("How much do you want to withdraw?")) balances [usernames. index (current_user)] = withdraw(balances [usernames. index (current_user)], amount) display (balances [usernames. index (current_user)]) elif choice == "B": display (balances [usernames. index (current_user)]) elif choice == "C": current_user = changeUser(usernames) elif choice == "A": newUser(usernames, passwords, balances) elif choice == "E": printUserInfo(file_name, usernames, passwords, balances) print("Thank you for using BankApp! Hope you have a nice day!") else: break print("Invalid option! Please try again.")
Expert Answer:
Answer rating: 100% (QA)
File before File after running program Terminal output Code whileloopprintType D to deposit moneyTyp... View the full answer
Related Book For
Applying Communication Theory For Professional Life A Practical Introduction
ISBN: 9781506315478
4th Edition
Authors: Marianne Dainton, Elaine D. Zelley
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Sara was sitting at her desk on just the second day of her new job. Her desk was relatively clear, with the exception of her computer, phone and a welcoming bouquet of flowers and balloons provided...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
A hollow-fiber membrane device is operated to concentrate a bacterial suspension. The flow rate of cell suspension into the fibers is 350 kg/min. The inlet cell suspension is comprised of 1.0 wt%...
-
In calculating AMTI, when is the adjustment for personal and dependency exemptions made? What is the reason for the adjustment?
-
Determine the reactions at the supports and then draw the moment diagram. Assume A is fixed. EI is constant. 500 lb 800 lb/ft D. -20 ft- 15 ft -20 ft-
-
Determine whether each of the following is true or false. In each case, assume \(P\) is located at \(t=0\) and \(F\) is located at \(t=n\), and the \(A\) s are spread uniformly over the planning...
-
Presented below is information related to Rembrandt Inc.s inventory. Determine the following: (a) The two limits to market value (i.e., the ceiling and the floor) that should be used in the...
-
2. There are two kinds of people, who are those with college degrees and those without college degrees. Assume that they are all white-collar workers. The wage status is described in Table 1. Table...
-
Using the Public MACRO BITCOIN scorecard spreadsheet (linked in its associated masterclass lesson - Long Term 32), create a COPY of it and perform a complete analysis for the date 22/2/2022....
-
Q6: A food truck near the University of Windsor specializes in healthy sandwiches. The sandwiches are prepared fresh each morning and any unsold sandwiches are donated to a food bank. Each sandwich...
-
You have recently been promoted as an information systems specialist at Amazon.You are required to investigate the organization's Human Resource information system to determine the type of HRIS which...
-
Hide Assignment Information Instructions OPTION 1 This option must be selected for NYSED Coaching Certification Final paper - Coaching Assignment Please pick a specific sport ( for example:SOCCER)...
-
The company has the following information for the 1st quarter of its operation during the taxable year 2021: Description January February March Current Sales Vatable Sales/Receipts 5,500,000...
-
What are the salient features of a quality issue as perceived by consumers and organizations, respectively, delineating the nuanced viewpoints from both ends of the spectrum?
-
The hotel has a total of 300 available rooms. On March 24th 240 rooms were occupied. 180 rooms asked that the sheets not be changed. The result of the reduction labor and operations cost for the 180...
-
Dersch Co. purchased a machine on January 1, 2014, for $1,500,000. Using the table below, calculate the annual depreciation expense for each year of the machine's life (estimated at 5 years or 50,000...
-
On January 1, 2018, Khalid Ltd., which follows IAS 17, entered into an eight-year lease agreement for three dryers. Annual lease payments for the equipment are $28,500 at the beginning of each lease...
-
Lisa, Steve, and Chen were feeling triumphant. Just 3 months ago, their company, Ryan Project Systems, had merged with Gierig Strategien AG, a consulting firm headquartered in Germany. At the time,...
-
Jason was a man with a plan. Immediately after graduating from college, he created his own cleaning company. He started off cleaning houses doing all of the dirty work by himself, but over time, he...
-
For more than 80 years, Hope Medical Center had serviced its local residents as a privately run, not-for-profit community hospital. However, with the rapidly escalating cost of medical care, last...
-
Powerhouse Ltd purchased machinery on 2 January 2019, at a cost of $800 000. The machinery is depreciated using the straightline method over a useful life of 8 years with a residual value of $80 000....
-
The purchases and sales of Big Flower Pty Ltd of one brand of lawn fertiliser for the year ended 31 December 2019 are contained in the schedule below. The selling price up to 30 June was $12 per unit...
-
In groups of four or five, consider the following information. On 1 July 2019, Stevenson Pty Ltd, a proprietary company with three shareholders, acquired some property by issuing 100 000 shares to...
Study smarter with the SolutionInn App