Page 126 - CA_Blue( J )_Class9
P. 126

8             c=2*3.142*r;
                     9             System.out.println("Area of a Circle "+a);

                    10             System.out.println("Circumference of a Circle "+c);
                    11         }

                    12     }
                        Input the value:                         You will get the following output:
















                  6.4.2 During Method Call
                  Using this procedure, we can take values in variables at the time of execution. The methods that are called during
                  execution have enclosed parameters which are used to pass input values from the user.

                                  Write a Java program to take the radius of a circle using method call and print the area and
                   Program 5
                                  circumference.
                     1     class method_call
                     2     {

                     3         public static void main(double r)

                     4         {
                     5             double a,c;
                     6

                     7             a=3.142*r*r;
                     8             c=2*3.142*r;

                     9             System.out.println("Area of a Circle "+a);
                    10             System.out.println("Circumference of a Circle "+c);

                    11         }
                    12     }

                       Input the value:                    You will get the following output:















                   124    Touchpad Computer Applications-IX
   121   122   123   124   125   126   127   128   129   130   131