Java program to calculate interest

Views: 142   

Following program shows you how to calculate interest.
In this program we get investment, interest rate and time from user and calculate interest using following formula
Interest = investment X interestRate X time / 100

import java.util.Scanner;

public class BasicMath15 {

    public static void main(String[] args) {

        int investment;
        int interestRate;
        int time;

        Scanner in = new Scanner(;

        System.out.println("Enter investment:");
        investment = in.nextInt();

        System.out.println("Enter interest rate:");
        interestRate = in.nextInt();

        System.out.println("Enter number of years:");
        time = in.nextInt();

        int interest = investment * interestRate * time / 100;

        System.out.println("Interest amount is: " + interest);



Enter investment:
Enter interest rate:
Enter number of years:
Interest amount is: 48000
On By