Java Program To Calculate Simple Interest

This java program user input the principal amount, time period, and rate of interest then calculate simple interest .
import java.util.*;
class ranjan
 {
  public static void main(String args[])
  {
   Scanner sc=new Scanner(System.in);
   int p,t,r;
   System.out.print("Enter the principal amount = ");
   p=sc.nextInt();
   System.out.print("Enter the time period = ");
   t=sc.nextInt();
   System.out.print("Enter the rate of interest = ");
   r=sc.nextInt();  
   System.out.println("Simple interest = "+(p*t*r)/100); 
  }
 }

Output:

Enter the principal amount = 10000
Enter the time period = 2
Enter the rate of interest = 5
Simple interest = 1000

Post a Comment

0 Comments