Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Cost of Watching the Super Bowl
- % Determines how much it will cost to watch the super bowl
- % Notes and clarifications at the bottom of the code
- % Inputs and Variables
- P = input('Wattage of the television set\n')*10^-3;
- t = input('During in hours \n');
- cost = input('What is the cost per kWh in cents?\n');
- % Outputs and Equations
- W = P * t;
- Cost = W * cost;
- fprintf('The total cost is %i cents', Cost);
- %{
- The wattage given by the user should be in Watts, but the variable 'P'
- stores them in kW.
- This code can be used to calculate the cost of using electricity
- on any device the TV and program are arbitrary.
- %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement