contestada

Modify the RetirementGoal application from Chapter 6 Exercise 10A to display the amount of money the user will have if the user earns 4% interest on the balance every year.

Respuesta :

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%

Writting the code in java:

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

Ver imagen lhmarianateixeira
ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE