Knowee
Questions
Features
Study Tools

Mr. Agarwal invests certain sum at 5% per annum compound interest for three years. Write a program in Java to calculate: (a) the interest for the first year (b) the interest for the second year (c) the amount after three years. Take sum as an input from the user. Sample Input: Principal = ₹5000, Rate =10%, Time = 3 yrs Sample Output: Interest for the first year: ₹500 Interest for the second year: ₹550 Interest for the third year: ₹605

Question

Mr. Agarwal invests certain sum at 5% per annum compound interest for three years. Write a program in Java to calculate:

(a) the interest for the first year (b) the interest for the second year (c) the amount after three years.

Take sum as an input from the user. Sample Input: Principal = ₹5000, Rate =10%, Time = 3 yrs Sample Output: Interest for the first year: ₹500 Interest for the second year: ₹550 Interest for the third year: ₹605

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple Java program that calculates the compound interest for each year and the total amount after three years:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter the principal amount:");
        double principal = scanner.nextDouble();

        System.out.println("Enter the rate of interest:");
        double rate = scanner.nextDouble();

        double firstYearInterest = (principal * rate) / 100;
        System.out.println("Interest for the first year: ₹" + firstYearInterest);

        double secondYearPrincipal = principal + firstYearInterest;
        double secondYearInterest = (secondYearPrincipal * rate) / 100;
        System.out.println("Interest for the second year: ₹" + secondYearInterest);

        double thirdYearPrincipal = secondYearPrincipal + secondYearInterest;
        double thirdYearInterest = (thirdYearPrincipal * rate) / 100;
        System.out.println("Interest for the third year: ₹" + thirdYearInterest);

        double amountAfterThreeYears = thirdYearPrincipal + thirdYearInterest;
        System.out.println("Amount after three years: ₹" + amountAfterThreeYears);
    }
}

This program first takes the principal amount and the rate of interest as input from the user. It then calculates the interest for the first year by multiplying the principal with the rate and dividing by 100. The interest for the second year is calculated in a similar way, but the principal for the second year is the sum of the original principal and the first year's interest. The same process is repeated for the third year. Finally, the total amount after three years is calculated by adding the third year's principal and interest.

This problem has been solved

Similar Questions

1) Rajiv deposited Rs.10,000 into a savings account that offers a simple interest rate of 6% per year. Ifhe keeps the money in the account for 3 years:a. Write the formula for finding the simple interest when the principal (P), rate (R), and time (T) aregiven.b. Calculate the total interest earned by Rajiv.c. Find the final amount in his savings account after the interest is added

Mr. Aggarwal invests ₹10,000 in a bank account that offers a simple interest rate of 15% per annum, compounded annually. After how many years will his investment quadruple?

A certain sum amounts to ₹57,600 at the end of five years and to ₹48,960 at the end of three years both being at simple interest. Find the rate of interest.

Avala borrowed Rs 4800 at a simple interest rate of 12.5% per annum for 2 years. Calculate the total interest paid by Avala?Options1400 1250 13001200

A sum becomes Rs 64827 in 3 years at 5% per annum compound interest. Find the sum.Rs 56000Rs 52000Rs 48000Rs 60000

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.