java Script SOP 11th
java Script SOP 11th
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.
<html>
<head>
<title> To accept integer & 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 ans is : " +ans);
</script>
</body>
</html>
OUTPUT
To accept two integers and display larger number of
them.
<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 the user entered number is
positive or negative.
<html>
<head>
<title>check 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>
Output
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.
To accept two positive or negative numbers and check
whether they are equal or not.
<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>
output
To accept a number and display the square of it.
<html>
<head>
<title>To accept number and display square of
it</title>
</head>
<body>
<script language = “Javascript”>
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.
<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.
To accept a string and calculate its length.
<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.
<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.
<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>