MATLAB: Help with script w/ more than one equation

elseififif statementscript

Best Answer

Computers do things in the order you tell them to:
TaxableIncome=input('Please provide taxable income in Australian Dollars:');
IncomeTax=0;
MedicareLevy=(TaxableIncome*0.015);
% TotalTax=IncomeTax + MedicareLevy; <== PUT THIS LINE AFTER THE INCOME TAX CALCULATION
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
TotalTax=IncomeTax + MedicareLevy;
fprintf('Income Tax is %f.\n', IncomeTax);
fprintf('Medicare Levy is %f.\n', MedicareLevy);
fprintf('Total Tax is %f.\n', TotalTax);
This worked when I ran it.
P.S. — Apologise for the delay, but it’s yesterday here!