I am doing a computer science assignment right now and im ha

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.

Solution

//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

I am doing a computer science assignment right now and im having a little bit of trouble. I have to use an \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site