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 W/ACCESS
- Posted below is a picture of a data table and a diagram of an experiment. In the experiment you rolled a marble down a ruler ramp off the end of a coffee table to observe projectiles and conservation of energy. You do 3 trials for each initial height. Each height is measured in meters. h= initial height of marble off of table Y= height of table off floor X= horizontal distance marble goes from edge of table to where it strikes the floor a) use the table to find information you need to solve for theoretical range and % of error in measured range.arrow_forwardAs the potential across the resistor increased, the current through the resistor increased. If the change in current is proportional to the voltage, the data should be in a straight line and it should go through zero. In these two examples how close is the y-intercept to zero? Is there a proportional relationship between voltage and current? If so, write the equation for each run in the form potential = constant x current. (Use a numerical value for the constant.)arrow_forwardHartley Electronics, Inc., in Nashville, producesshort runs of custom airwave scanners for the defense industry.The owner, Janet Hartley, has asked you to reduce inventory byintroducing a kanban system. After several hours of analysis, youdevelop the following data for scanner connectors used in onework cell. How many kanbans do you need for this connector?Daily demand 1,000 connectorsLead time 2 daysSafety stock 12 dayKanban size 500 connectorsarrow_forward
- MATLAB: Use a built-in MATLAB function to generate position vs. time data and plot the position of the vehicle with time for the entire journey. .arrow_forwardYou own a wheat warehouse with a capacity of 20,000bushels. At the beginning of month 1, you have 6,000 bushels of wheat. Each month, wheat can be bought and sold at theprice per 1000 bushels given in Table 46.The sequence of events during each month is as follows:a You observe your initial stock of wheat.b You can sell any amount of wheat up to your initialstock at the current month’s selling price.c You can buy (at the current month’s buying price) asmuch wheat as you want, subject to the warehouse sizelimitation.Your goal is to formulate an LP that can be used to determine how to maximize the profit earned over the next 10monthsarrow_forwardYou are the mechatronics engineer of a manufacturing plant. You decide to perform an analysis on a robot arm of the assembly line with the objective of optimizing its performance. After taking several readings of the speed of the arm’s end effector, you approximate its velocity to the function given below. v(t) = -t4 + 5t3 - 7t2 + 3t + 0.22 0 =< t =< 3 where the velocity is in ms-1 Use your knowledge of differentiation to sketch the velocity-time graph, clearly marking the critical points. Using the graph sketched in (a) above, estimate the velocity when t = 1.5 s Calculate the velocity of the function when t = 1.5 s by substituting to the velocity function. Compare this value to the value you estimated in b above.arrow_forward
- Engineering Economy A company has determined the price and the monthly demand of its products are related by the equation D = √775 - p, where p is the price per unit in dollar and D, is the monthly demand. The associated fixed costs are $2,125 per month and the variable costs are $100/ unit. Use this information to answer the following: a)What is the optimal number of units that should be produced and sold each month? b) What is the maximum profit? c)Determine the value of D that represents the break-even point?arrow_forwardMatlab code please or just some stepping stones to help.arrow_forwardSuppose your CFD code can handle nonelementary blocks. Combine as many blocks of Fig. as you can. The only restriction is that in any one block, the number of i-intervals and the number of j-intervals must be constants. Show that you can create a structured grid with only three nonelementary blocks. Renumber all the blocks and indicate how many i- and j-intervals are contained in each block. Add up all the cells and verify that the total number of cells does not change.arrow_forward
- No need guideline answer ok. Solve both write RRL. ABOUT THESE 2 ITEMS. NOTE NO NEED EXTRA EXPLANATION ONLY NEED FOR OTH 1 PARAGRAPH EACH PUT REF END POINTS OK. DONT NEED GUIDELINE OKK. IF ANSWER GUIDELINE I WILL DISLIKE OKK 1. height of sweet potato plants; 2. programable speed of a rover: . something that says that a rover is programmed via speed, that it doesn't matter if the weight of the rover is decreasing from time to time. something that says that if you programmed a rover to go 5kph it will remain 5kph even if you put something heavy on it.arrow_forwardMy professor said that I need to use the numbers as shown on the picture and make the exact graph that is also shown on the picture. But I don’t know how to put this in to MATLAB. Please send the code that makes the graph that is shown in the picture. Make it 100% exactly the same.arrow_forwardplease write a matlab codearrow_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