Dremendo Tag Line

Calculate simple interest in Java

Input - Question 14

In this question, we will see how to input principal, rate, time in Java programming using the java input and find the simple interest. To know more about java input click on the java input lesson.

Q14) Write a program in Java to input principal, rate, time and find the simple interest.

Formula: Simple Interest = (Principal * Rate * Time) / 100

Program

import java.util.Scanner;

public class Q14
{
    public static void main(String args[])
    {
        int p,r,t,si;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter principal ");
        p=sc.nextInt();
        System.out.print("Enter rate ");
        r=sc.nextInt();
        System.out.print("Enter time ");
        t=sc.nextInt();
        si=(p*r*t)/100;
        System.out.print("Simple Interest=" + si);
    }
}

Output

Enter principal 5000
Enter rate 10
Enter time 1
Simple Interest=500
video-poster