# Program to find Simple Interest and Compound Interest in PL/SQL

Prerequisite PL/SQL introduction

In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.

Given principal(p), rate(r), time(t), the task is to calculate the simple interest and compound interest.

Examples:

Input: p = 1500
r = 5
t = 3
Output: SI = 225, CI = 1736.44

Input: p = 2700
r = 7
t = 8
Output: SI = 1512, CI = 4639.1


Formula for Simple Interest: Formula for Compound Interest: Where:
P: Principal (original amount)
R: Rate of Interest (in %)
T: Time period

Below is the required implementation:-

   DECLARE     --declaration of principal variable      p  NUMBER(9, 2);      ----declaration of rate variable      r  NUMBER(9, 2);      --declaration of time period variable      t  NUMBER(9, 2);      --declaration of simple interest variable      si NUMBER(9, 2);      ci NUMBER(9, 2);  BEGIN     --Code Block Start       --assigning principal values      p := 33000;         --assigning rate  values      r := 7;         --assigning time period values      t := 6;         --To calculate SI by simple       --mathematical formula      si := ( p * r * t ) / 100;         ci := p * Power (1 + ( r / 100 ),t);         --Print Result of SI.........      dbms_output.Put_line('Simple Interest = '                          ||si);         dbms_output.Put_line('Compound interest = '                          || ci);  END;  --End program

Output

Simple Interest = 13860
Compound interest = 49524.1

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.