Page 280 - CA_Blue( J )_Class9
P. 280

6             pp= p/cp*100;                          //Calculation of profit percentage
                     7             System.out.println("Profit : "+p);  //Displaying profit
                     8            System.out.println("Profit Percentage : "+pp); //Displaying Profit percentage

                     9         }

                    10     }
                  You will get the following output:

                         Profit : 4.5
                         Profit Percentage : 12.676056338028168

                                                         VARIABLE DESCRIPTION
                             NAME              DATATYPE                           DESCRIPTION
                        sp               double                 Selling Price
                        cp               double                 Cost Price
                        p                double                 Profit
                        pp               double                 Profit Percentage
                  (iii)  Programs based on Input through Scanner class.

                                  Write a program to input the basic salary of an employee and print the gross salary and net
                   Program 4
                                  salary according to the following condition.
                                  da= 25% of basic
                                  hra = 12% of basic
                                  pf=8% of basic
                                  gross = basic + da + hra
                                  net salary = gross – pf
                     1  import java.util.*;                                      //Importing “util” package
                     2  class salary                                             //Class name

                     3  {

                     4      public static void main()
                     5      {
                     6          Scanner sc= new Scanner(System.in);

                     7          double basic,da,hra,pf,gross,netsal;             //Declaration of Variable
                     8          System.out.print("Enter the Basic Salary : ");

                     9          basic=sc.nextDouble();
                    10          da=basic * 0.25 ;                                       //Dearness Allowance

                    11          hra = basic * 0.12;                                     //House Rent Allowance
                    12          pf = basic * 0.08;                                      //Provident Fund

                    13          gross = basic + hra+da;                                 //Gross Salary
                    14          netsal=gross - pf;                                      //Net Salary

                    15          System.out.println("Basic : "+basic);                   //Displaying Values


                   278    Touchpad Computer Applications-IX
   275   276   277   278   279   280   281   282   283   284   285