Write a MATLAB program that computes the amount of income tax a person
needs to pay according to the following table:
Salary Range ($) Base Tax ($) Percentage of Excess
0.00 14,999.99 0.00 15
15,000.00 29,999.99 2,250.00 18
30,000.00 49,999.99 5,400.00 22
50,000.00 79,999.99 11,000.00 27
80,000.00 149,999.99 21,600.00 33
>= 150,000.00 32,000.00 40
For example, if a persons salary is $2,000.00, the income tax the person needs to pay is
$2,250.00 (base tax for the second range) plus 18% of the excess salary over $15,000.00 (that
is, 18% of $5,000). Therefore, the total tax due is $2,250.00 plus $900.00, which is
$3,150.00.
Your program should first prompt the user to input a salary amount (with the prompt of
Please enter the salary amount: ”), then based on the amount and the above
table calculate the total amount of income tax. Your program should output to the command
window the total amount of tax as follows:
The total tax due is:
x
where x is the calculated total amount of tax with two digits after the decimal point. For
example, if the calculated amount is $3,150, the value should be displayed as 3150.00. If the
salary amount inputted by the user is negative, your program should output to the command
window:
invalid input

댓글 수: 3

nanren888
nanren888 2012년 2월 23일
The main thing, Richelle, is to make a start.
Jan
Jan 2012년 2월 23일
@Richelle: What have you done so far and which problems occurred?
Walter Roberson
Walter Roberson 2012년 2월 23일
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

2012년 2월 23일

편집:

2013년 10월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by