Write a program of function withdraw money, Programming Languages

Write a function called withdraw (in the file 'withdraw.m') that simulates withdrawing money from a bank account. The function takes a single input argument, a positive scaler double value. If the user passes a value that is not scaler or is not greater than 0, your function should throw an error.

The function should access a global variable called BALANCE. Subtract the amount of the withdrawal from the BALANCE variable. If the subtraction would take BALANCE to less than 0, leave BALANCE unchanged and throw an error. Also, if BALANCE is not yet defined, thow an error.

Finally you are limited to 5 withdrawals from your bank account. Use a persistent variable to store how many times the withdrawal function has been used. On the fifth and all subsequent calls to the function it should automatically throw an error and not perform the withdrawal.

The function should return only one value, the number of withdrawals remaining.

From the 'hw4.m' file set the global value BALANCE to some initial value. Then show some example calls to the withdraw function, followed by a display of the remaining value of BALANCE. You should demonstrate the various error conditions, but make sure to catch all errors and display the error message without forcing the script to terminate.

 

 

Posted Date: 3/22/2013 7:08:22 AM | Location : United States







Related Discussions:- Write a program of function withdraw money, Assignment Help, Ask Question on Write a program of function withdraw money, Get Answer, Expert's Help, Write a program of function withdraw money Discussions

Write discussion on Write a program of function withdraw money
Your posts are moderated
Related Questions
What is an abstract class:   Abstract class is stated as an abstract concept that cannot be instantiated or comparing to interface this can have some implementation and interface c

Windows Presentation Foundation Designed by Microsoft Technologies, the Microsoft Technologies windows Display Groundwork (or WPF) is a computer-software graphic subsystem for maki

A specification of a function TOARR is given below. function TOARR(n in Int, s in Stack of Int) return in Array of Int pre n ≥ 0. post The returned value is an array of size

Consider a system that has the following UML models: Use Case for CalculateTotalProjectCost Trigger: End of each month Normal Flow of Events For each project in the pro

Question: (a) (i) Describe what an XML Data Island is and outline the restrictions of using a Data Island. (ii) The following XML file book.xml is used to keep track of a l

Of the 6,325 kindergarten students who participated in the study, almost half or 3,052 were eligible for a free lunch program. The categorical variable sesk (1 == free lunch, 2 = n

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Using os.walk, write a script that will print the filenames of zero length files. It should also print the count of zero length files.

Vacation Envy - Travel and Photo Sharing Website Site Overview- Vacation Envy is a travel as well as photo-sharing site. Make your travel map, share photos and show off al

My kinect hand cursor only works for main menu but when it goes to another page it wouldn''t work.. especially when there is for camera feed