Page 322 - Web Applications (803) Class 11
P. 322
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. Write JavaScript code for the following:
• Accept three numbers from the user and display the largest number.
• Accept principal amount and rate from the user. Calculate simple interest as follows:
Principal Amount Time
>=25000 10 years, 5 years otherwise
• Accept salary of an employee from the user. Deduct the income tax from the salary on the following basis
and finally display income tax and net salary.
Salary Income Tax
> `15000 30%
Between `7000 – `15000 20%
<`7000 10%
• Calculate discount price base on total amount. If amount is less than 10000 then no discount. If amount is
less than 20000 then discount is 5%. If amount is less than 30000 then discount is 10%. If amount is more
than 50000 then discount is 15%. [CBSE Handbook]
2. Predict the output of the following code:
<HTML>
<BODY>
<SCRIPT>
var num1=prompt("Enter a number");
document.write("Number entered is :"+num1);
document.write("<br> <br>");
if (num1%2==0) {
document.write(num1+" is an even number");}
else {
document.write(num1+" is an odd number");}
</SCRIPT>
</BODY>
</HTML>
The switch Statement
Due to use of multiple if statements, the program becomes more complex and lengthier. To avoid such problem,
JavaScript provides switch statement. The switch statement executes certain statements depending on user’s choice.
The case statement is used to define different cases where each case has a unique label and a set of statements
associated with it.
320 Touchpad Web Applications-XI

