Create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed.

Respuesta :

ijeggs

Answer:

/* interest = principal amount * rate*time

Total amount = principal + interest

*/

See a java program with a method that implements the solution in the explanation section

Explanation:

public class num6 {

   public static void main(String[] args) {

       double capital = 5000;

       int noYears = 1;

       double intRate = 0.02;

       System.out.println("Interest is "+simpleInterest(capital,noYears,intRate));

       double totalAmount = capital + simpleInterest(capital,noYears,intRate);

       System.out.println("Total Amount is "+totalAmount);

   }

   public static double simpleInterest(double capital, int timeInYears, double rateInPercentage){

       double interest = capital*timeInYears*rateInPercentage;

       return interest;

   }

}