Page 281 - CA_Blue( J )_Class9
P. 281

16          System.out.println("Dearness Allowance : "+da);
                  17          System.out.println("House Rent Allowance : "+hra);

                  18          System.out.println("Gross Salary : "+gross);
                  19          System.out.println("Net Salary : "+netsal);

                  20      }}
                 You will get the following output:

                        Enter the Basic Salary: 3500
                        Basic: 3500.0

                        Dearness Allowance: 875.0
                        House Rent Allowance: 420.0

                        Gross Salary: 4795.0
                        Net Salary: 4515.0

                                                        VARIABLE DESCRIPTION
                            NAME              DATATYPE                           DESCRIPTION
                       basic            double                Basic Salary
                       da               double                Dearness Allowance
                       hra              double                House Rent Allowance
                       pf               double                Provident Fund
                       gross            double                Gross Salary
                       netsal           double                Net Salary

                 (iv)  Programs based on Mathematical methods.

                  Program 5      Write a program to input a number and print the square root and cube root of the number.

                   1      import java.math.*;                                       //Importing “math” package

                   2      import java.util.*;                                       //Importing “util” package
                   3      class mathfunction                                        //Class name

                   4      {
                   5          public static void main()

                   6          {
                   7             Scanner sc= new Scanner(System.in);

                   8             double n,sr,cr;                                          //Variable Declaration
                   9             System.out.println("Enter a number ");

                  10             n=sc.nextDouble();
                  11             sr=Math.sqrt(n);                                         //Square root function

                  12             cr=Math.cbrt(n);                                         //Cube root function




                                                                                             Internal Assessment  279
   276   277   278   279   280   281   282   283   284   285   286