Page 369 - Webapplication11_C11_Flipbook
P. 369

On running the above program, we get the following output:



















                 When you click on the “OK” button, with the message “This page says”. Then a new window appears as shown below:


















                                                 Lab Assignment ‘n Activity                    #Computational Thinking




                   1.  Predict the output for the following code:
                       <HTML>
                       <BODY>
                       <SCRIPT>
                       //Calculate area or circumference of circle depending on user choice
                       var radius = prompt("Enter radius of circle");
                       var choice = parseInt(prompt("Enter 1 to calculate area 2 for circumference"))
                       document.write("Radius Entered: "+radius+"<br> <br>");
                       switch (choice) {
                           case 1: circle_area=3.14*radius*radius;
                                   document.write("Area of Circle "+circle_area+"<BR>");
                                         break;
                          case 2: circle_circum=2*3.14*radius;
                                   document.write("Circumference of Circle "+circle_circum+"<br>");
                                   break;
                           default:  document.write("Invalid Choice")
                                   }
                       </SCRIPT>
                       </BODY>
                       </HTML>



                                                                                                  JavaScript Part 1  367
   364   365   366   367   368   369   370   371   372   373   374