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

Please I want the program to be written in matlab. Write a program that takes a

ID: 3827829 • Letter: P

Question

Please I want the program to be written in matlab.

Write a program that takes a number as input from the user. Then it calculate and returns the total electricity bill based on the followings: For first 50 units (i.e., 1-50) Rs. $0.50/unit For next 100 units (i.e., 51-150) Rs. $0.75/unit For next 100 units (i.e., 151-250) Rs. $1.20/unit For unit above 250 Rs. $1.50/unit An additional surcharge of 20% is added to the bill If the input is not a positive number, your program must output a sensible message and finish. So, for instance, here is the calculation you need to do for 750 unit:50*$0.50+100*$1.20+500*$1.50 + surcharge.

Explanation / Answer

clear
clc
Units=input('Enter Units:');
bill=0;
if Units<0
disp('Wrong Input')
else
for i=1:Units
if i<51
bill=bill+.50;
  
elseif i>50&&i<151
bill=bill+.75;
  
elseif i>150&&i<251
bill=bill+1.20;
else
bill=bill+1.50;
end
end
end
bill=bill+.2*bill;
fprintf('The total bill is : %.2f ',bill)