Selection Statements
Due Date: 07.03
1. Objectives
Completing
all tasks in this assignment will help you write nested selection statements.
Because this
assignment is due Wednesday, it is shorter than you should normally expect.
First skim, and then carefully read the entire assignment before starting any
tasks.
2. A mathematical function
A
mathematical function T has the following structure:
T(y)
= 200 when
y
is below 10000
=
200 + 0.1 (y – 10 000) when
y
is between 10000 and 20000
=
1,200 + 0.15 (y – 20 000) when y is between 20001 and 50000
=
5,700 + 0.25 (y – 50 000) when y is above 50000
Write a script file called TFunc.m that mimics the output of this function after prompting the user
for a value for
y. Test your program on the cases y = 5000, 17000, 25000, and 75000.
3. Taxes in Timbuctoo
The income
tax code in Timbuctoo works as follows: the first 30,000 rupees of income is taxed at
25%,
the next 30,000
rupees at 30%,
and any amount above 60,000 rupees at 40%. Write a program that
accepts as input an income amount and computes and prints the correct tax
amount to be paid in Timbuctoo.
Save your script file as Taxes.m and test your program on the following incomes R15925, R47500, R963000
(R = rupees).
4. Submitting Your Work
Type your
name, student ID, and the date at the top of each file in commented form. At the bottom of files Tfunc.m and Taxes.m, put your answers for the
various cases (also in commented form). Sign and staple all documents, then
submit them in lecture on Wednesday.