---
# System prepended metadata

title: for 迴圈(homework 1_5)

---

# for 迴圈(homework 1_5)
public static void main(String [] args) {
	
	int P = 150;
	int year = 10;
	double i = 1+0.02;
    double sum = 0;
	//double sum = P*Math.pow(i,year)

	    for(year = 1;year<11;year++) {
	    
	    	sum = P*Math.pow(i,year);
	    	
	}
	    System.out.println("本金加利息共"+sum+"萬元");
	
