/**
* cusomized by: mathhoang
* Y!M: vietnam_hoangminhnguyen@yahoo.com
* addr: http://mathhoang.blogspot.com
* subject: java tutorials source code
*/
package Exercise4;
import java.util.*;
public class Example4 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("How much do you want to receive after retiring");
double goal = in.nextDouble();
System.out.println("How much do you put into your account every year");
double payment = in.nextDouble();
System.out.println("Interest in the bank every year");
double interest = in.nextDouble();
double balance = 0;
int years = 0;
while (balance < goal) {
balance += payment;
double intr = balance * interest/100;
balance += intr;
years++;
}
System.out.println("You can retire after: " + years + " years");
}
}
---
name: nguyen minh hoang
Y!M : vietnam_hoangminhnguyen@yahoo.com
net name: mathhoang
No comments:
Post a Comment