Page 150 - CA_Blue( J )_Class9
P. 150

7                     System.out.println("Area of a equilateral triangle "+ a);
                     8                 }

                     9             }

                    Input:                                         You will get the following output:


















                   Program 4      Write a program to calculate the Compound Interest (CI).
                                  CI = P(1+R/100)  - P Here P is principal amount.
                                                t
                                  R is the annual interest rate.
                                  t is the time the money is invested or borrowed for.


                     1     import java.util.*;
                     2     class compoundinterest
                     3         {

                     4             public static void main ()
                     5             {

                     6                 Scanner sc= new Scanner (System.in);
                     7                 double p,r,t,ci=0.0;

                     8                 System.out.println("Enter the principal amount: ");
                     9                 p=sc.nextDouble();

                    10                    System.out.println("Enter the rate of interest: ");
                    11                 r=sc.nextDouble();

                    12                    System.out.println("Enter time: ");
                    15                   t=sc.nextDouble();

                    16                   ci = (p * (Math.pow((1 + r / 100), t))) - p;
                    17                System.out.println("Compound Interest: "+ci);

                    18             }
                    19         }








                   148    Touchpad Computer Applications-IX
   145   146   147   148   149   150   151   152   153   154   155