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
On-line fair and ethical share trading system (Olfest) A system is required that allows on-line customers to buy and sell stock market shares in a selection of companies. B

HOW CAN I DESIGN A MOBILE WEB BROWSER LIKE OPERA MINI. USING VISUAL BASIC? HELP ME.

Consider the operation of a line of supermarket checkouts and the profiles of customers and their shopping baskets. Use a random number generator to create the data for these profi

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

I WANT TO MAKE PROJECT IN ARM LANGUAGE CAN YOU HELP ME

Determine the address accessed by each of the following instruction if DS=1100H, BX=0200H, LIST=0250H AND SI=0500H-: 1) MOV LIST[SI],EDX?0250+0500+11000=11750 2

I need an application that will gather data from one SQL Database and update another. Data is contained in dbo.CallList with following fields: Customer_ID, AlreadyPickedUp, Phone_N

what is a microprocessor? types of microprocessors? advantages disadvantages

In this assignment you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application. You

1. Introduction The Tube Challenge is a Guinness World Records challenge that tests both the physical and mental abilities of the person trying to break it. The main components