Using the computational knowledge in python it is possible to write a code that makes a balance function per year from a gain of 4%
import java.util.Scanner;
public class RetirementGoal2 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int years;
double savings;
System.out.println("Number of years the user has until retirement");
years = s.nextInt();
while (years <= 0) {
System.out.println("Please enter a valid number");
years = s.nextInt();
}
System.out.println("Enter amount of money you can save actually");
savings = s.nextDouble();
while (savings <= 0) {
System.out.println("Please enter a valid number");
savings = s.nextDouble();
}
double amount = 0;
// calculating the amount after given years and with 4% interest
for (int i = 1; i < years; i++) {
amount += savings;
amount *= 1.04;
}
//printing result
System.out.printf("Amount after " + years + " years : %.2f" , amount);
}
}
See more about JAVA at brainly.com/question/12975450
#SPJ1