Created
April 26, 2015 19:47
-
-
Save leighhalliday/2bbfc86a1859e60d9a08 to your computer and use it in GitHub Desktop.
Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var totalGen = 19; | |
var totalMW = 0; | |
// Loop through for each generator | |
for(i = 1; i <= totalGen; i++) { | |
// Is this an even or odd generator? | |
if (i % 2 == 0) { | |
// Is this generator 4 or less? | |
// Keep track of how many MW (megawatts) this generator produces | |
if (i <= 4) { | |
var genMW = 62; | |
} else { | |
var genMW = 124; | |
} | |
// Let's add to the total MW we have generated | |
totalMW = totalMW + genMW; | |
console.log("Generator #" + i + " is on, adding " + genMW + " MW, for a total of " + totalMW + " MW!"); | |
} else { | |
// Odd numbered generators are off | |
console.log("Generator #" + i + " is off."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generator #1 is off. | |
Generator #2 is on, adding 62 MW, for a total of 62 MW! | |
Generator #3 is off. | |
Generator #4 is on, adding 62 MW, for a total of 124 MW! | |
Generator #5 is off. | |
Generator #6 is on, adding 124 MW, for a total of 248 MW! | |
Generator #7 is off. | |
Generator #8 is on, adding 124 MW, for a total of 372 MW! | |
Generator #9 is off. | |
Generator #10 is on, adding 124 MW, for a total of 496 MW! | |
Generator #11 is off. | |
Generator #12 is on, adding 124 MW, for a total of 620 MW! | |
Generator #13 is off. | |
Generator #14 is on, adding 124 MW, for a total of 744 MW! | |
Generator #15 is off. | |
Generator #16 is on, adding 124 MW, for a total of 868 MW! | |
Generator #17 is off. | |
Generator #18 is on, adding 124 MW, for a total of 992 MW! | |
Generator #19 is off. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment