I'm having trouble passing an object from a method function to another function.
I want to pass the obj.federaltax and obj.provincialTax to my calc_totalTax func to calcluate the totalTax but all i'm getting is an empty value for totalTax.
classdef calcTax properties income = input('enter annual income: '); federalTax; provincialTax; totalTax; end function obj = calc_federalTax(obj) if obj.income <= 46605 obj.federalTax = obj.income*15/100; else obj.federalTax = obj.income*15/100; end end function obj = calc_provincialTax(obj) if obj.income <= 42960 obj.provincialTax = obj.income*5.05/100; else obj.provincialTax = obj.income*9.15/100; end end function obj = calc_totalTax(obj) obj.totalTax = obj.provincialTax + obj.federalTax disp(totalTax) end end end
Best Answer