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
Explain the Continue statement - Computer Programming? This is alike to break but is encountered less frequently. It merely works within loops where its effect is to force an imm

Advantages of asp.net mvc framework MVC is a conventional style design that many designers are acquainted with. Some kinds of Web programs will advantage from the MVC structur

specify the function of the instruction and also specify whether its right or wrong-: (5) 1) MOV [BX],AX? Register Indirect addressing 2) MOV CX,[BX+DI]?Base plus index add

I have doubt in this section .do-while loop.could you able to clear it for me.

Write a Fortran LOGICAL FUNCTION, called "is_prime", which determines if a given integer value is a prime number or not (A prime number is a natural number which has only two disti

Write a program that will allow the user to input the corners of a triangle. The program will draw small yellow circles for each input point, then draw the triangle and calculate t

showing work Ubuntu system or either opensuse

JSP QUIZ ASSIGNMENT SHOULD BE FUNCTIONAL ON ECLIPSE QUIZ HAS TOTAL 20 QUESTIONS REGARDING VARIOUS CAPITALS OF COUNTRIES. WELCOME PAGE OFFERS USER TO ENTER HIS NAME. THEN USER C

about how to create the program in c

maake a programme in C of HR system