Page 195 - Web Applications (803) Class 12
P. 195

Experiential Learning
                                                 Lab Assignment ‘n Activity



                    Complete the following activities and tick on the circle.
                      Write JavaScript code for the following:

                      Assign grade to a variable. Based on the grade display the bonus of the employee.
                                       Grade                    Bonus (in ` )
                                         A                         2000
                                         B                         1500
                                         C                         1000
                                         D                          700

                       Assign amount to a variable. If the amount is greater than ` 200 display “Use an auto”, else if the
                       amount is between ` 200–` 50, display “Use shared Ola/Uber” else if amount is between ` 5–` 20
                       display “Use the public bus” otherwise display “Walk to your school”.



                 Practice Question

                    <html>
                    <body>
                    <script>
                    var sal=580000;
                    if(sal>=500000)

                    itax=0.30*sal;
                    else if(sal>=350000 && sal<500000)
                    itax=0.20*sal;
                    else
                    itax=0.10*sal;
                    document.write("Salary ="+sal+"<BR>");
                    document.write("Income Tax ="+itax);
                    </script>

                    </body>
                    </html>
                 Output of the preceding program is as follows:




















                                                                                          Web Scripting—JavaScript   193
   190   191   192   193   194   195   196   197   198   199   200