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

Prerequisite
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:
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


Contact Us