Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
cs-142:bulb [2016/09/06 22:36]
kseppi
cs-142:bulb [2016/09/06 22:38] (current)
kseppi
Line 2: Line 2:
 #include <​iostream>​ #include <​iostream>​
 using namespace std; using namespace std;
 + 
 /* This program decides on which light bulb is the better deal /* This program decides on which light bulb is the better deal
   Inputs: ​   Inputs: ​
Line 45: Line 45:
         float bulb1Power = 0.005; // KW         float bulb1Power = 0.005; // KW
  float bulb2Power = 0.100; // KW  float bulb2Power = 0.100; // KW
 + 
  float totalCost1;  float totalCost1;
  float totalCost2;  float totalCost2;
 + 
  float powerCost1;  float powerCost1;
  float powerCost2;  float powerCost2;
- +  
- + 
  float hoursPerDay = 16; // sleep for 8 hours  float hoursPerDay = 16; // sleep for 8 hours
  float daysPerYear = 365;  float daysPerYear = 365;
  float powerRate = 0.075; // 7.5 cents per kwh  float powerRate = 0.075; // 7.5 cents per kwh
 + 
  powerCost1 = bulb1Power * hoursPerDay * daysPerYear * powerRate;  powerCost1 = bulb1Power * hoursPerDay * daysPerYear * powerRate;
  powerCost2 = bulb2Power * hoursPerDay * daysPerYear * powerRate;  powerCost2 = bulb2Power * hoursPerDay * daysPerYear * powerRate;
 + 
  totalCost1 = bulb1Cost + powerCost1;  totalCost1 = bulb1Cost + powerCost1;
  totalCost2 = bulb2Cost + powerCost2;  totalCost2 = bulb2Cost + powerCost2;
 + 
  cout << "Bulb 1 Cost " << totalCost1 << endl;  cout << "Bulb 1 Cost " << totalCost1 << endl;
  cout << "Bulb 2 Cost " << totalCost2 << endl;  cout << "Bulb 2 Cost " << totalCost2 << endl;
- system("​pause"​);​+ // system("​pause"​);​
 } }
 </​code>​ </​code>​
cs-142/bulb.txt · Last modified: 2016/09/06 22:38 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0