Uncategorized

Write a Java Program to define a function which accept values of P, R, T and calculate simple interest

Write a Java Program to define a function which accept values of P, R, T and calculate simple interest.

import java.io.*;
import java.util.*;

class SimpleInterest
{
	void interest(int P, int r, int t)
	{
		double si = (P*r*t)/100;
		System.out.println("Simple Interest = " + si );
	}
  public static void main(String args[ ])
  {
  	Scanner sc = new Scanner(System.in);
  	int p, r, t;
  	System.out.println("Enter p =");
  	p = sc.nextInt();
  	System.out.println("Enter r =");
  	r = sc.nextInt();
  	System.out.println("Enter t =");
  	t = sc.nextInt();
  	SimpleInterest ob = new SimpleInterest( );
  	ob.interest( p, r, t );
  }
}

Click to comment

Leave a Reply

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

To Top