Client Side Scripting (JavaScript) 11th Information Technology Practicals Skill Set 3 Solutions Maharashtra Board
Balbharati Maharashtra State Board Class 11 Information Technology Solutions Practicals Skill Set 3 Client Side Scripting (JavaScript) Textbook Exercise Questions and Answers.
Class 11 Information Technology Practicals Skill Set 3 Exercise Solutions
SOP 1: Create a JavaScript program for the following using appropriate variables, JavaScript inbuilt functions, and control structures.
- To accept an integer and display the result by multiplying it with 3.
- To accept two integers and display a larger number of them.
- To check whether the user entered number is positive or negative.
Answer:
To accept integer and display the result by multiplying it with 3.
<!DOCTYPE html>
<head>
<title>To accept integer and display the result by multiplying it with 3.</title>
</head>
<body>
<script language=âjavascriptâ> var a,no,ans;
a=prompt(Enter any valueâ);
no=parseInt(a);
ans=no*3;
document.
write(âThe answer is :â+ans);
</script>
</body>
</html>
To accept two integers and display larger number of them.
<!DOCTYPE html>
<head>
<title>To accept two integers and display larger number of them.</title>
</head>
<body>
<script language=âjavascriptâ>
var a,b;
a=prompt(âEnter first valueâ);
b=prompt(âEnter second valueâ);
if(a>b)
document.write(âa is large number than b â);
else
document. write(âb is large number than aâ);
</script>
</body>
</html>
To check whether, user entered number is positive or negative.
<!DOCTYPE html>
<head>
<title>To check whether, user entered number is positive or negative</title>
</head>
<body>
<script language=âjavascriptâ>
var a,no;
a=prompt(âEnter any numberâ);
no=parseInt(a);
if(no>0)
document.write(âNumber is Positiveâ);
else
document.write(âNumber is Negativeâ);
</script>
</body>
</html>
SOP 2: Create a JavaScript program for the following using appropriate variables, JavaScript inbuilt functions, and control structures.
- To accept two positive or negative numbers and check whether they are equal or not.
- To accept a number and display the square of it.
- To check whether the accepted integer is multiple of 3 or multiple of 7.
Answer:
To accept two positive or negative numbers and check whether they are equal or not.
<!DOCTYPE html>
<head>
<title>program3</title>
</head>
<body>
<script language=âjavascriptâ> var no1,no2;
no1=prompt(âEnter first numberâ);
no2=prompt(âEnter Second numberâ);
if(no1==no2)
document.write(âBoth are equalâ);
else
document.write(âGiven numbers are not equalâ);
</script>
</body>
</html>
To accept number and display square of it.
<!DOCTYPE html>
<head>
<title>To accept number and display square of it</title>
</head>
<body>
<script language-âj avascriptâ>
var no,sqr;
no=prompt(âEnter Any numberâ);
sqr=no*no;
document, write (âThe Square is=â+sqr);
</script>
</body>
</html>
To check whether the accepted integer is multiple of 3 or multiple of 7.
<!DOCTYPE html>
<html>
<head>
<title>To check whether the accepted integer is multiple of 3 or multiple of 7.</title>
</head>
<body>
<script language=JavaScript>
var a;
a=prompt(âEnter your first interger / numberâ);
if(a%3==0 | | a%7==0)
alert(âmultiple of 3 or 7â);
else
alert(ânot a multiple of 3 or 7â);
</script>
</body>
</html>
SOP 3: Create a JavaScript program for the following using appropriate variables, JavaScript inbuilt string functions, and control structures.
- To accept a string and calculate its length.
- To accept a string and display it in lowercase and uppercase.
- To check whether the length of the string is 4 or greater.
Answer:
To accept a string and calculate its length.
<!DOCTYPE html>
<head>
<title>program8</title>
</head>
<body>
<script language=âjavascriptâ>
var a;
a=prompt(âEnter stringâ);
document.write(âThe length is=â+a.length);
</script>
</body>
</html>
To accept string and display it into lowercase and uppercase.
<!DOCTYPE html>
<head>
<title> To accept string and display it into lowercase and uppercase</title>
</head>
<body>
<script language=âjavascriptâ>
var a;
a=prompt(âEnter any stringâ);
document.write(â<br>Entering Strings â+a);
document.write(â<br>Lowercase=â+a.toLowerCase());
document.writeln(â<br>Uppercase=â+a.toUpperCase());
</script>
</body>
</html>
To check whether the length of string is 4 or greater.
<!DOCTYPE html>
<html>
<head>
<title> JavaScript</title>
</head>
<body>
<script language=JavaScript>
var a,b;
a=prompt(âEnter your textâ);
b=a.length;
if(b=4 || b>=4)
alert(ââyour length is 4 or greaterâ);
else
alert(âyour text length is below 4â);
</script>
</body>
</html>
SOP 4: Create event-driven JavaScript programs for the following using appropriate variables, JavaScript inbuilt functions, and control structures.
To accept numbers and validate if the given value is a number or not by clicking on the button.
To calculate the addition and division of two numbers.
Answer:
To accept number and validate if the given value is a number or not by click
<!DOCTYPE html>
<html>
<head>
<title> To accept number and validate if the given value is a number or not by clicking on the button.
</title>
</head>
<script language-âJavaScriptâ>
function display()
{
var a,b;
a=form1.t1;value;
if(a>=0)
alert(âValue is a numberâ+â â+a);
else
alert(âValue is a stringâ+â â+a);
}
</script>
</head>
</body>
<form name=form1>
Enter Value: <Input type=text name=t1><br><br>
<Input type=button value=Check onClick=âdisplay()â>
</form>
</body>
</html>
To calculate addition and division of two numbers.
<!DOCTYPE html>
<head>
<title>To calculate addition and division of two numbers.</title>
<script langauge=âjavascriptâ>
function add()
{
var a,b,result;
a=f1.t1.value;
b=f1.t2.value;
result=parselnt(a)+parselnt(b);
document.write(âThe Addition is =â+result);
}
function div()
{
var a,b,d;
a=f1.t1.value;
b=f1.t2.value;
d=parselnt(a)/parselnt(b);
document.write(âThe Divide is =â+d);
}
</script>
</head>
<body>
<form name=âf1â>
1st Number : <input type=âtextâ name=ât1â><br>
2nd Number : <input type=âtextâ name=ât2â><br>
<input type=âbuttonâ value=âAdditionâ name=âb1â onClick=âadd()â>
<input type=âbuttonâ value=âDivisionâ name=âb2â onClick=âdiv()â>
</form>
</body>
</html>