mathlab solution 1) The electricity accounts of residents in a very small town a
ID: 2086351 • Letter: M
Question
mathlab solution
1) The electricity accounts of residents in a very small town are calculated as follows: if 500 units or less are used the cost is 2 cents per unit; if more than 500 units are used, the cost is $10 for the first 500 units, and then 5 cents for every unit in excess of 500; Write a program which asks you to enter the number of units and then calculates the cost of electricity for this unit. Run your m-file for the number of units of 300, 500 and 700. (Put the m-file and the answers to your report.)Explanation / Answer
clc
clear
% program for cost estimation
prompt='please enter the number of unit of electricity? ';
x=input(prompt);
if x<=500
c=0.02*x;
else
c=10+0.05*x;
end
fprintf('value of cost in dollar=%i ',c);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.