Answer to Question #60884 in Java | JSP | JSF for karthikraja

Question #60884
Problem : The power of compounding



Manish has realized the power of compounding. Since the days he started earning, he has diligently set aside a small corpus which he saves from his monthly salary and deposits in his bank account. Bank pays him interest every month. Manish is also a determined investor and refrains from withdrawing anything from this account because he now believes in power of compounding. Given investment corpus, fixed annual rate of interest and maturity period calculate the amount the Manish will end up saving at the end of his tenure.

Submit
1
Expert's answer
2016-07-19T08:38:02-0400
import java.util.Scanner;

public class BankDeposit {

public static void main(String[] args) {
double investCorpus;
double annualRate;
double maturityPeriodInDays;
double savingAmount;

Scanner in = new Scanner(System.in);
System.out.println("Please enter an investment corpus");
investCorpus = Double.valueOf(in.nextLine());
System.out.println("Please enter a fixed annual rate of interest");
annualRate = Double.valueOf(in.nextLine());
System.out.println("Please enter a maturity period in days");
maturityPeriodInDays = Double.valueOf(in.nextLine());
savingAmount = amountOfSavings(investCorpus, annualRate, maturityPeriodInDays);
System.out.println("Your savings to the end of " + maturityPeriodInDays + " days will be = " +
String.format("%.2f", savingAmount));
}

/**
* calculate the amount
* @param invest
* @param rate
* @param period
* @return the amount of saving till the end of the period
*/
public static double amountOfSavings(double invest, double rate, double period) {
final int DAYSINTHEYEAR = 365;
final int PROCENTS = 100;
return invest + invest * (rate / PROCENTS) * (period / DAYSINTHEYEAR);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS