Skip to content

Instantly share code, notes, and snippets.

@chrisladd
Created September 29, 2014 19:57
Show Gist options
  • Save chrisladd/d290bcd04bbb9e0e050c to your computer and use it in GitHub Desktop.
Save chrisladd/d290bcd04bbb9e0e050c to your computer and use it in GitHub Desktop.
ua-assembly-for-loops
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