Concept explainers
You are to program part of the interface for a simple atm. When the user inserts their card and types the correct pin (you do NOT have to write this part of the program), the system will place the users’ checking account balance balance in a variable CBal and the users’ saving account balance in SBal.
You are to write a function that will accept SBal and CBal as inputs and return two variables NewCBal and NewCBal containing the checking and savings balances after the transaction is completed. The function should do the following:
- Display a menu titled “Main Menu” with the following three options.
- Get cash
- Get balance
- Quit
- If “Get cash” is selected, another menu titled “Withdrawal amount” with the following four items is displayed:
- $20
- $60
- $100
- $200
- After selecting an amount, a menu titled “From which amount?” should be displayed showing the following two options:
- Checking
- Savings
- At this point, the program should verify that the selected amount contains sufficient funds for the requested withdrawal.
- If not, a message should be displayed that says, “Sorry. You do not have sufficient funds in your SSSS account to withdraw $XX” where SSSS is either Savings or Checking and $XX is the selected withdrawal amount.
- It funds are available, the program should call a function Disp20(x), where x is the number of $20 bills to dispense. (See the following note about Disp20.) After that, the withdrawal amount should be subtracted from the appropriate balance.
- After processing the “Get cash” request, the program should return to the main menu.
Note About Disp20(x): The purpose of this function is to dispense the requested number of $20 bills—that is, to shove x bills out of the slot in the ATM machine. This does not really exist since we do not have an ATM machine to work with. Thus, if you try to run your code, you will get an error (“Undefined function..”).
In order to test your program, add the following function to your current path:
Where x is the number of bills to be dispensed.
This allows you to know if the program reached the proper location in the code. It is fairly common in software development to use a “dummy” function in the place of a real one when the device to be controlled has not been completed or is not available in order to help verify whether the software is reaching the correct places in the code for various situations.
- If “Get Balance” is selected, another menu titled “Which account?” should appear with the two choices:
- Checking
- Savings
and the program should then display “Your SSSS balance is $bb.bb.,” where SSSS is either Savings or Checking and $bb.bb is the balance in the selected account.
- After processing the “Get balance” request the program should return to the main menu.
- If Quit is selected, the function should return to the calling program with the updated balances in NewCBal and NewSBal. Note that the new balances will be equal to the original balances if no money was drawn from an account, but they must still be returned in the two new balance variables.
If the user closes a menu rather than making a selection, a warning message should be displayed and the user given two more chances to make a selection from that menu. If they still close the menu on the third attempt, an error message should be displayed and control should return to the main program after making sure that NewCBal and NewSBal were set as appropriate based on earlier transactions.
Want to see the full answer?
Check out a sample textbook solutionChapter 19 Solutions
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
- Design a Moore type synchronous state machine with three external inputs A1, A2, A3 and one output signal F. The output F goes to 1 when A1.A2.-A3 = 1 at the next system timing event. The output F stays at 1 as long as A3=0; otherwise, the output goes to 0. (Note: use a positive edge-triggered D flip-flop in the design) Write a VHDL code to describe the implementation of one-digit decimal counter using PROCESS.arrow_forwardState all the formulae associated with the Isothermal Process.arrow_forward: +0 العنوان solle не Am 4 A pump draws water through a 300-mm diameter cast iron pipe, 15m long from a reservoir in which the water surface is 4.5 m higher than the pump and discharges through a 250- mm diameter cast iron, 75 m long, to an elevated tank in which the water surface is 60 m higher than the pump. Q=0.25 m³/s. Considering f-0.02 and the coefficients for minor head losses (k entrance 0.5, k bend 0.35, and K exit -0.5), compute the power of the pump. ۳/۱ ۲/۱ 4.5 m Kentrance 300 mm dia. 15 m Length 250 mm dia. 75 m Length kpend kexit 60 m ostlararrow_forward
- A 100 m length of a smooth horizontal pipe is attached to a large reservoir. A attached to the end of the pipe to pump water into the reservoir at a volume flow rate of 0.01 m³/s. What pressure (gage) must the pump produce at the pipe to generate this flow rate? The inside diameter of the smooth pipe is 150mm. Dynamic Viscosity of water is 1*103 Kg/(m.s). K at the exit of the pipe is 1. pump 10 m D=150mm L= 100 m- Pumparrow_forward: +0 العنوان solle не A 4 A numn drawe water through 200 ۳/۱ ۲/۱ A heavy car plunges into a lake during an accident and lands at the bottom of the lake on its wheels as shown in figure. The door is 1.2 m high and 1 m wide, and the top edge of the door is 8 m below the free surface of the water. Determine the hydrostatic force on the door if it is located at the center of the door, and discuss if the driver can open the door, if not; suggest a way for him to open it. Assume a strong person can lift 100 kg, the passenger cabin is well-sealed so that no water leaks inside. The door can be approximated as a vertical rectangular plate. 8 m E ✓ Lakearrow_forwardTwo concentric plain helical springs of the same length are wound out of the samewire circular in cross section and supports a compressive load P. The inner springmean diameter 200 mm. Calculate the maximum stress induced in the spring if theconsists of 20 turns of mean dimeter 160 mm and the outer spring has 18 turns ofdiameter of wire is equal to 10 mm and Pis equal to 1000 N. (Take Ks=1)arrow_forward
- t 1+2\xi pu +962гz P 1 A heavy car plunges into a lake during an accident and lands at the bottom of the lake on its wheels as shown in figure. The door is 1.2 m high and I m wide, and the top edge of the door is 8 m below the free surface of the water. Determine the hydrostatic force on the door if it is located at the center of the door, and discuss if the driver can open the door, if not; suggest a way for him to open it. Assume a strong person can lift 100 kg, the passenger cabin is well-sealed so that no water leaks inside. The door can be approximated as a vertical rectangular plate. 加 8 m 1.2 m Lake -20125 DI 750 x2.01 5 P 165 Xarrow_forward11. If Sin(x+α) = 2Cos(x-a); prove that: tan x= 2- tana 1-2 tanaarrow_forward12. If Sin(x-a)= Cos(x+α); prove that: tan x=1.arrow_forward
- : +0 العنوان solle не A 4 A numn drawe water through 200 ۳/۱ ۲/۱ A heavy car plunges into a lake during an accident and lands at the bottom of the lake on its wheels as shown in figure. The door is 1.2 m high and 1 m wide, and the top edge of the door is 8 m below the free surface of the water. Determine the hydrostatic force on the door if it is located at the center of the door, and discuss if the driver can open the door, if not; suggest a way for him to open it. Assume a strong person can lift 100 kg, the passenger cabin is well-sealed so that no water leaks inside. The door can be approximated as a vertical rectangular plate. 8 m E ✓ Lakearrow_forward۲/۱ - | العنوان A heavy car plunges into a lake during an accident and lands at the bottom of the lake on its wheels as shown in figure. The door 1.2 m high and 1 m wide, and the top edge of the door is 8 m below the free surface of the water. Determine the hydrostatic force on the door if it is located at the center of the door, and discuss if the driver can open the door, if not; suggest a way for him to open it. Assume a strong person can lift 100 kg, the passenger cabin is well-sealed so that no water leaks inside. The door can be approximated as a vertical rectangular plate. 8 m Lakearrow_forward- | A pump draws water through a 300-mm diameter cast iron pipe, 15m long from a reservoir in which the water surface is 4.5 m higher than the pump and discharges through a 250- mm diameter cast iron, 75 m long, to an elevated tank in which the water surface is 60 m higher than the pump. Q-0.25 m³/s. Considering f- 0.02 and the coefficients for minor head losses (k entrance 0.5, k bend 0.35, and K exit -0.5), compute the power of the pump. Kexit 250 mm dia 75 m Length 60 m العنوان 300 mm dia. 15 m Length -UZ kentrance 11421 Kpend osthor oster ۲/۱arrow_forward
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY