Question

In: Computer Science

In this problem, you will need to create a state machine that stimulates a simple bank...

In this problem, you will need to create a state machine that stimulates a simple bank account in Python 3.6. Any withdrawal when the balance is less than $100 incurs a $5 charge. The state machine should fulfill the following:

• The starting balance is specified when instantiating the object.

• The output of the state machine is the current balance after the transaction.

Sample interaction:

>>> acct = SimpleAccount (110)

>>> acct . start ()

>>> acct . step (10)

120

>>> acct . step ( -25)

95

>>> acct . step ( -10)

80

>>> acct . step ( -5)

70

>>> acct . step (20)

90

>>> acct . step (20) 110

Solutions

Expert Solution

Code with indenatation:

Output:

____________________________________________________________________________________

Code:

import threading
class SimpleAccount(threading.Thread):
balance=0
  
def __init__(self,b):
threading.Thread.__init__(self) #handling thread
self.balance = b #setting value
def step(self,val):
if(val<0): #val is negative
if(self.balance >100): #if bal greater than 100
self.balance=self.balance+val
print(self.balance)
else:
self.balance=self.balance+(val-5) #bal is less than 100 then -5 extra
print(self.balance)
else: #if val is postive
self.balance=self.balance+val #adding value
print(self.balance)
  

  
acct=SimpleAccount(110)
acct.start()
acct.step(10)
acct.step(-25)
acct.step(-10)
acct.step(-5)
acct.step(20)
acct.step(20)

_________________________________________________________________________________________

NOTE: You can add many threads simultaneously..


Related Solutions

A company borrows $35000 at 14.75% simple interest from State Bank to purchase equipment. State Bank...
A company borrows $35000 at 14.75% simple interest from State Bank to purchase equipment. State Bank requires the company to make monthly interest-only payments and pay the full $35000 at the end of 10 years. In order to meet the 10 year obligation of $35000,the company makes equal deposits at the end of each month into a sinking fund with Wolf Savings. The sinking fund earns 6.75% compounded monthly. Note: This problem is set to allow for an answer of...
Create a simple 0, 1 integer model for a situation or problem you face in your...
Create a simple 0, 1 integer model for a situation or problem you face in your life. Is there an optimal solution for your problem? What type of model would you use to create an optimal solution? Explain.
When you use an automated teller machine (ATM) with your bank card, you need to use...
When you use an automated teller machine (ATM) with your bank card, you need to use a personal identification number (PIN) to access your account. If a user fails more than three times when entering the PIN, the machine will block the card. Assume that the user's PIN is "1234" and write a program in python that asks the user for the PIN no more than three times, and does the following: 1. If the user enters the right number,...
IN PYTHON When you use an automated teller machine (ATM) with your bank card, you need...
IN PYTHON When you use an automated teller machine (ATM) with your bank card, you need to use a personal identification number (PIN) to access your account. If a user fails more than three times when entering the PIN, the machine will block the card. Assume that the user’s PIN is “1234” and write a program that asks the user for the PIN no more than three times, and does the following: •If the user enters the right number, print...
For this final problem we will create two samples of dice rolls. First You need to...
For this final problem we will create two samples of dice rolls. First You need to roll two dice in the standard way 25 times and record the results. Then roll two dice in a “lucky” way 25 times and record the results. As you complete this problem use the known standard deviation for the sum of two dice : σ1 = 2.415 and σ2 = 2.415 (a) Write down the results of your rolls and find the average for...
•Create a state machine that is sort of like a computer mouse with right clicks and...
•Create a state machine that is sort of like a computer mouse with right clicks and left clicks. Instead it uses pB1 and pB2. –Two fast clicks of pB1 turns on led 1 for 5s –Click on pB2 from the idle state you simply turn on LED2 while the button is held in Below is a state machine I've set up to turn on an LED for 5 s if a pB is pushed one time, which is only a...
Need this in java .Create a simple login screen in java That lets people sign in...
Need this in java .Create a simple login screen in java That lets people sign in to the emergency room. It needs to ask for name, social,and DOB. Once all the information is received it then display the info back to them if any info is is missing have the program prompt the user to re enter their information.
Create a simple A3 problem solving report (Problem: Not enough cashiers in most stores in Spain)...
Create a simple A3 problem solving report (Problem: Not enough cashiers in most stores in Spain) (Fill out report from I – VI) I – Theme -Define problem II – Background (More information about the problem, why it’s important) III – Current condition (You could state 9 out of 10 times you have been there, you’ve experienced this problem, the problem’s effect on you as a customer) IV – Cause Analysis (the 5 why analysis) V – Target Condition (What...
You are an employee of the State bank of Vietnam and your bank participates in a...
You are an employee of the State bank of Vietnam and your bank participates in a range of forums and takes part in international discussions with other central banks. The topics include the state of the world economy and measures to ensure the stability of financial markets and to improve their structure. In addition, the bank also conducts research and studies on financial issues, compiles and releases statistics and engages in public relations activities. You have been asked to present...
In c# I need to create a simple payroll management system using visual basic and GUI....
In c# I need to create a simple payroll management system using visual basic and GUI. I also need to connect to SQL database. It needs a log in screen, inside the login screen it needs another screen to enter or edit employee information. It needs somewhere to enter hours worked for that specific employee, and another screen that can access reports.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT