HI, I have looked at other examples of fprintf, but my formatting on fare(4,75) is off and I am not sure why? fare(4,44) output is correct. Fare (4,75) should be 2.20 (80% of the full fare for 4 miles at 0.80* 2.75) Maybe I have just been looking at this for too long to figure it out.
>> fare(4,44) 2.75 >> fare(4,74) 2.754.00 >>function price = fare(d, a)if d <= 1 price2 = 2;elseprice2 = fprintf('%.2f',2 + (min(9, d-1) * 0.25) + (max(0, d-10) * 0.10));endif 18 >= a || a >= 60price2 = fprintf('%.2f',price2*0.80);end
Best Answer