I am doing a computer science assignment right now and im having a little bit of
ID: 3931953 • Letter: I
Question
I am doing a computer science assignment right now and im having a little bit of trouble. I have to use an "if" statement in MATLAB and im a little lost on how to use it.
I am trying to code: "GrossIncome <= TaxableIncome" then it equals "GrossIncome"
"GrossIncome > TaxableIncome" then it is "GrossIncome - TaxableIncome" which equals "Taxable"
I tried doing:
if GrossIncome <= TaxableIncome
fprintf(' GrossIncome ')
else
if GrossIncome > TaxableIncome
fprintf(' GrossIncome - TaxableIncome = Taxable ')
end
end
But it just prints it and does'nt actually do the math being done. Idk what coding to use to fix this. Thanks for the help.
Explanation / Answer
//Tested on online ocatve
GrossIncome=500%initial amount
TaxableIncome=400%initial amount
if GrossIncome <= TaxableIncome
% if condition is true then print the following
fprintf('%d',GrossIncome );
elseif GrossIncome > TaxableIncome
% if else if condition is true
fprintf('%d',GrossIncome - TaxableIncome);
end
/***********output**********/
Thanks a lot
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.