India's Largest Free Online Education Platform

java program to calculate simple interest

java program to calculate simple interest

Code:

import static java.lang.System.out;
import java.util.Scanner;
public class Simple_Interest {
    public static void main(String args[]) {
        out.println("This is a program for calculating Simple Interest");
        out.println("Enter Principle Value");
        Scanner Sc = new Scanner(System.in);
        float p = Sc.nextFloat();
        out.println("Enter Rate");
        float r = Sc.nextFloat();
        out.println("Enter Time in year");
        float t = Sc.nextFloat();
        float SI = (p * r * t) / t;
        out.println("Calculated SI at Principle Vale=" + p + ", Rate=" + r + ", Time=" + t + " is: " + SI);
    }
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!