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
wat is- m=5; n=3; x=m++-n+++m;

Write a Perl script that prints the contents of a file Write a Perl script that prints the contents of a file, prefixing each line with a line number. The script should acc

You will design and implement a program that will • analyse the various characteristics of a maze, represented by a particular coding of its basic con- stituents into numbers store

I am getting error at business layer object in code behind page.

A large logistics company requires a software system to support the business processes associated with managing shift patterns of employees and making the associated payments. The


The first task is to extend the  NeoPhoneBookEntry and  NeoPhoneBook classes to accommodate for  four additional contact  details:  Ringtone,  Vibration Pattern,  Led Pattern  and

Windows Workflow Foundation Microsoft windows Work-flows foundation (WF) is an Enthusiasm technological innovation that provides an API, an in-process workflow website, and a rehos

Program for Operate the Rolodex Rolodex is a rotating file, usually used to record business contact information. Cards are inserted in alphabetic order by name. You operate th

program take integer from user and print in alphabets