Created
September 29, 2014 19:57
-
-
Save chrisladd/d290bcd04bbb9e0e050c to your computer and use it in GitHub Desktop.
ua-assembly-for-loops
This file contains hidden or 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
public class ForLoops { | |
public static void main(String[] args) { | |
for (int i = 99; i >= 0; i = i - 1) { | |
System.out.println(i + " bottles of root beer on the wall."); | |
} | |
// compound interest means that you make a certain amount of money | |
// and then your reinvest what you earned, combined with the principal. | |
// for example: | |
double interestRate = 0.025; // 2.5 % interest rate | |
double principal = 10000.0; // investment is 10 thousand dollars | |
double firstYearInterestEarned = principal * interestRate; // you make the principal times the interest rate on the first year. | |
System.out.println("Year 1: " + firstYearInterestEarned); | |
double secondYearInterestEarned = (principal + firstYearInterestEarned) * interestRate; | |
System.out.println("Year 2: " + secondYearInterestEarned); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment