Advertisement
hiddenGem

Electricity Usage

Jun 17th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.63 KB | None | 0 0
  1. %% Cost of Watching the Super Bowl
  2. % Determines how much it will cost to watch the super bowl
  3. % Notes and clarifications at the bottom of the code
  4.  
  5. % Inputs and Variables
  6. P = input('Wattage of the television set\n')*10^-3;
  7. t = input('During in hours \n');
  8. cost = input('What is the cost per kWh in cents?\n');
  9.  
  10. % Outputs and Equations
  11. W = P * t;
  12. Cost = W * cost;
  13. fprintf('The total cost is %i cents', Cost);
  14.  
  15. %{
  16. The wattage given by the user should be in Watts, but the variable 'P'
  17.     stores them in kW.
  18. This code can be used to calculate the cost of using electricity
  19.     on any device the TV and program are arbitrary.
  20. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement