Page 285 - CA_Blue( J )_Class9
P. 285

You will get the following output:
                        Enter the price of an item : 6500
                        Price of the item : 6500.0
                        Discount : 650.0
                        Discounted Price : 5850.0
                                                        VARIABLE DESCRIPTION
                                   NAME              DATATYPE                    DESCRIPTION
                              pr               double                Price of the item
                              dis              double                Discount on price
                              dispr            double                Discounted Price



                                 Write a program to input the name of the customer, previous meter reading and present
                  Program 9
                                 meter reading of the electricity meter and print the name of the customer and bill to be
                                 paid. The calculation will be done according to the following criteria:
                                 Units consumed = present meter reading – previous meter reading.
                                 Units                       Rate
                                 First 150 units             2.5/- per unit
                                 Next 200 units              4.5/- per unit
                                 Next 500 units              7.5/- per unit
                                 More than 850 units         8.5/- per unit
                                 Also, a service charge of Rs. 250 per bill
                   1      import java.util.*;                                       //Importing “util” package

                   2      class electricitymeter                                    //class name
                   3      {
                   4          public static void main()

                   5          {

                   6              Scanner sc= new Scanner(System.in);
                   7              String name;                                      //Variable Description
                   8              int prv, pre , u ;

                   9              double  billamount = 0.0;
                  10              System.out.print("Enter Name of the customer : ");

                  11              name = sc.next();
                  12              System.out.print("Enter previous meter reading : ");

                  13              prv=sc.nextInt();
                  14              System.out.print("Enter present meter reading : ");

                  15              pre=sc.nextInt();
                  16              u=pre-prv;                                        //Unit consumed

                  17              if(u<=150)                                        //Condition checking
                  18                  billamount = u * 2.5;                         //calculation of billamount




                                                                                             Internal Assessment  283
   280   281   282   283   284   285   286   287   288   289   290