Write a program of function withdraw money, Programming Languages

Assignment Help:

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.

 

 


Related Discussions:- Write a program of function withdraw money

Matlab, I need to write code to compute matrix multiplication without usin...

I need to write code to compute matrix multiplication without using built in function.

No Linux Audible, Why no Audible support for Linux? Maybe they should use a...

Why no Audible support for Linux? Maybe they should use a browser interface?

Microprocessor, what is a microprocessor? types of microprocessors? advanta...

what is a microprocessor? types of microprocessors? advantages disadvantages

Create a linux shell, Create a linux shell (in other words, write a C/C++ p...

Create a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as yourRollNumber-currentDirector

Provide example of function, Provide Example of Function? An illustrati...

Provide Example of Function? An illustration of a function definition main() { message(); } /* header */ message() { /*bodystarts here*/ printf ("Example for function

Explain what is html language with an example, Explain what is HTML languag...

Explain what is HTML language with an example? HTML is the HyperText Markup Language. HTML files are text files featuring semantically tagged elements. HTML filenames are suff

C++, fow to I write a emplate that reads a set of numbers typed at the keyb...

fow to I write a emplate that reads a set of numbers typed at the keyboard into an array of T

List recursion to de ne the function, Use list recursion to de ne the funct...

Use list recursion to de ne the function mySum which takes as input an integer and a list of integers and returns the list obtained by adding every element of the list by the rst

Develop a program on behavior of hospital personnel, A psychologist is inte...

A psychologist is interested in learning about the voting behavior of college students.  (4 points for each part.)Design a study which would yield data on this topic. a. state y

Scheme assignment, A function that takes a list with at least 4 numbers and...

A function that takes a list with at least 4 numbers and if three of the numbers sum is equal to the remaining numbers return #t else return #f

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd