Help with script w/ more than one equation?
显示 更早的评论
TaxableIncome=input('Please provide taxable income in Australian Dollars:');
IncomeTax=0;
MedicareLevy=(TaxableIncome*0.015);
TotalTax=IncomeTax + MedicareLevy;
if IncomeTax>0 && MedicareLevy>0
end
if TaxableIncome>=0
end
if TaxableIncome>=0 && TaxableIncome<=6000
elseif TaxableIncome>6000&& TaxableIncome<=20000
IncomeTax=0.17*(TaxableIncome-6000);
elseif TaxableIncome>20000 && TaxableIncome<=50000
IncomeTax=2380+0.30*(TaxableIncome-20000);
elseif TaxableIncome>50000 && TaxableIncome<=60000
IncomeTax=11380+0.42*(TaxableIncome-50000);
elseif TaxableIncome>60000
IncomeTax=15580+0.47*(TaxableIncome-60000);
end
fprintf('Income Tax is %f.\n', IncomeTax);
fprintf('Medicare Levy is %f.\n', MedicareLevy);
fprintf('Total Tax is %f.\n', TotalTax);
This is the question I am answering but I am not sure why my Total Tax isnt adding the Medicare Levy and the Income Tax:
3.11 The author of this book now lives in Australia. Australia is a great place
to live, but it is also a land of high taxes. In 2002, individual citizens and
residents of Australia paid the following income taxes: Taxable Income (in A$) Tax on This Income
$0–$6,000 None
$6,001–$20,000 17¢ for each $1 over $6,000
$20,001–$50,000 $2,380 plus 30¢ for each $1 over $20,000
$50,001–$60,000 $11,380 plus 42¢ for each $1 over $50,000
Over $60,000 $15,580 plus 47¢ for each $1 over $60,000 In addition, a flat 1.5% Medicare levy is charged on all income. Write a
program to calculate how much income tax a person will owe based on this information. The program should accept a total income figure from the user and calculate the income tax, Medicare levy, and total tax payable by the individual.| *
* 采纳的回答
更多回答(1 个)
John wick
2021-2-9
I know this is really old, but I have the same assignmet and I was having trouble with the first fprintf function. Hope this helps out another student in the far future
clear
clc
disp('This program calculates the taxes for Australia')
personincome=input('Enter the persons total income:');
tax=0;
MedLev=.015*personincome;
if (personincome<=6000)
tax=0;
elseif 6001>=20000
tax=.75*(personincome-6000);
elseif 20001<=50000
tax=2380+.30*(personincome-20000);
elseif 50001<=60000
11380+.42*(personincome-50000);
else
tax=15580+.47*(personincome-60000);
end
Tottx=personincome+MedLev;
fprintf('For an income of %g the taxes are:\n',personincome);
fprintf('Medicare Levy:%.0f\n',tax);
fprintf('Income Tax:%.0f\n',MedLev);
fprintf('Total Tax:%.0f\n',Tottx);
类别
在 帮助中心 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!