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
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 doub

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit

We are looking for Pool Services Software Our company Pool Hands LLC is looking to build software for our internal use. We would like the software built therefore that it could

The next major set of tasks to tackle are delete and update. Version control systems typically version updates to a ?le and only store the differences between the ?les. Two system

All programs have to be done in console application. Program 1, 2 and 3 are due on 2/11/12 Program 4, 5, and 6 are due on 2/18/12 Program 7, 8, and 9 are due on 2/25/12 Program 10

ASP.NET and ASP.NET AJAX ASP.NET AJAX, formerly known as "Atlas", is an Enthusiasm rendering of an AJAX centered structure, designed for ASP.NET (although it can be used on other s

Write a script called 'prob1.m' that solves for the variables y, and z in terms of a user inputed x. The variables y and z are defined as follows: y = x - 30                when

Carnivorous Carla only eats pizza if it has at least three of the following ingredients: ham, pepperoni, salami, italian sausage, bacon. You have the function contains() to check w

Memory Hierarchy for Linux Systems A cache line has one or more valid bit(s), tag entry and list of bytes in a block in one set of a cache, as shown below: If you were

1. Write a function that converts a character array to a signed decimal integer. Function prototype must be as follows: int asciiToInt( char *str, unsigned char* eflag) YOU MAY NO