Page 148 - CA_Blue( J )_Class9
P. 148

Example of Math.sin() :   double r = Math.sin(radian);    // Output : 0.5
                  Example of Math.cos():   double r = Math.cos(radian);   // Output : 0.865

                  Example of Math.tan():   double r = Math.tan(radian);   // Output : 0.5776




                                                                                         21 st
                   Some More Programs                                                  Century   #Coding & Computational Thinking
                                                                                        Skills

                                  Write a program to find the increase in kinetic energy of a body of mass 500 g, when its
                   Program 1
                                  velocity increases from x m/s to y m/s.
                     1     import java.util.*;

                     2     class kinetic_energy
                     3         {
                     4             public static void main ()

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

                     7                 double massg, masskg, v1, v2, ke;
                     8                 System.out.println("Enter v1 : ");

                     9                 v1=sc.nextDouble();
                    10                 System.out.println("Enter v2 : ");

                    11                 v2=sc.nextDouble();
                    12                 massg= 500;

                    13                 masskg= 500.0/1000.0;
                    14                 ke=1.0/2.0 * masskg * (Math.pow(v2,2) - Math.pow(v1,2));

                    15                 System.out.println("The increase in Kinetic energy is: "+ke + "J");
                    16             }

                    17         }

                  You will get the following output:























                   146    Touchpad Computer Applications-IX
   143   144   145   146   147   148   149   150   151   152   153