Computer Science, asked by aparna257, 1 year ago

write a program in java to assign principal amount (P),rate of interest (R) and Time(T). calculate and print the simple interest using the formula: SI=(PRT)/100​

Answers

Answered by QGP
23

Simple Interest - Java

We need to first take User Input for the values of Principal Amount (P), Rate of Interest (R) and Time Period (T). We will do this by using Scanner.

We store them as double type values. Then, we calculate the Simple Interest using the formula and display it.

 \rule{300}{1}

import java.util.Scanner;       //Importing Scanner

public class SimpleInterest     //Creating Class

{

   public static void main(String[] args)      //The main function

   {

       Scanner scr = new Scanner(System.in);   //Creating Scanner Object

       //Take User Input for P, R and T

       System.out.print("Enter Principal Amount (P): ");

       double P = scr.nextDouble();

       System.out.print("Enter Rate of Interest (R): ");

       double R = scr.nextDouble();

       

       System.out.print("Enter Time Period (T): ");

       double T = scr.nextDouble();

       //Calculate Simple Interest I = (PRT)/100

       double I = (P*R*T)/100;

       //Display the Simple Interest

       System.out.println("Simple Interest = "+I);

   }

}

Attachments:
Answered by divyaprakash007
0

Answer:

import java.util.*;

import java.io.*;

public class Program {

 

public static void main(String []args) throws IOException{

 

   InputStreamReader read = new InputStreamReader(System.in);

   BufferedReader in = new BufferedReader(read);

   

   System.out.print("Enter Principal Amount: ");

      double principal = Double.parseDouble(in.readLine());

      System.out.print("Enter Rate of Interest: ");

      double rate = Double.parseDouble(in.readLine());

 System.out.print("Enter Time Period: ");

      double time = Double.parseDouble(in.readLine());

      double interest = (principal * rate * time)/100;

      System.out.println("Simple Interest = "+interest);

     

         

}}

Explanation:

Enter Principal Amount: 5000

Enter Rate of Interest: 5

Enter Time Period: 1

Simple Interest = 250.0

Similar questions