Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Medication dosage by weight A machine administers medication dosage based on wei

ID: 2267624 • Letter: M

Question

Medication dosage by weight A machine administers medication dosage based on weight. Write an it-elseif-else statement that assigns the appropriate dosageAmount given userWeight Weight (kg) Dosage (units Less than 50 50-140 Greater than 140 10 20 30 Ex: If userWeight is 65, then dosageAmount is assigned with 20. Your Function Save C Reset MATLAB Documentation 1 function dosageAmount CalculateDosage(userWeight) 21% use neight : User's weight in kg 4 Assign dosageAmount with the appropriate amount given userweight dosageAmount = 0; 71 end Code to call your function C Reset 1 CalculateDosage(65) Run Function

Explanation / Answer

% MAIN PROGRAM
clc;
clear all;
weight1 = input('Enter weight of the user weight in kg ');
out = calculatedosage(weight1);
disp(' Dosage = ');
disp(out);

% DOSAGE FUNCTION PROGRAM

function dosage = calculatedosage(weight1)
dosage = 0;
b =weight1;
if (b< 50)
dosage = 10;
elseif (b >= 50 && b<=140)
dosage = 20;
elseif( b > 140)
dosage = 30;
end
end