Question: Complete the function Calculate Toll. Use an if statement to determine if the vehicle's weight is over 5,000 pounds. Ex: Calculate Toll(10, 3500) yields 20.

Complete the function Calculate Toll. Use an if statement to determine if the vehicle's weight is over 5,000 pounds. Ex: Calculate Toll(10, 3500) yields 20. Hint: An if statement has a closing end statement. Function Save C Reset I MATLAB Documentation 1 function finalToll = CalculateToll(base Toll, vehicleWeight) 2 % baseToll: The base toll to cross a bridge in dollars 3 % vehicleWeight: Weight of a vehicle in pounds 4 5 6 7 % TODO: Assign finalToll with base Toll finalToll = 20; if (vehicleWeight>5000) finalToll=final(Toll+baseToll; finalToll=2*finalToll; 8 9 10 11 12 % TODO: If vehicleWeight is over 5,000 pounds, increase finalToll by 4 dollars finalToll = basetotal+4 % TODO: Assign finalToll with twice the value of finalToll 13 14 15 end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
