Page 242 - CA_Blue( J )_Class10
P. 242

To write a function double calculate (double inc) to calculate the annual tax and print the tax
                Program 4     and the salary after deducting the tax according to the following criteria.

                                    Annual Income                       Tax
                                    Up to 1000                          5%
                                    1001 to 5000                        7.5%
                                    5001 to 10000                       10%
                                    Above 10000                         15%

                 1  import java.util.*;
                 2  class function_tax

                 3  {
                 4      public static double calculate(double inc)

                 5      {   double tax;
                 6          if(inc<=1000)

                 7              tax = 0.05 * inc;
                 8          else

                 9          if(inc<=5000)
                10              tax = 0.075 * inc;

                11          else
                12          if(inc<=10000)

                13              tax = 0.10 * inc;
                14          else

                15              tax = 0.15 * inc;
                16          return tax;

                17      }
                18      public static void main()

                19      {   Scanner sc= new Scanner(System.in);
                20          double ann_inc,tax,total;

                21          System.out.println("Enter Amount : ");
                22          ann_inc=sc.nextDouble();

                23          tax=calculate(ann_inc);
                24          total=ann_inc-tax;

                25          System.out.println("Tax : "+ tax);
                26          System.out.println("Income after tax : "+total);
                27      }

                28  }




                240240  Touchpad Computer Applications-X
   237   238   239   240   241   242   243   244   245   246   247