Professional Documents
Culture Documents
Web Development WS 2 - Sahul Kumar Parida (20BCS4919)
Web Development WS 2 - Sahul Kumar Parida (20BCS4919)
Web Development WS 2 - Sahul Kumar Parida (20BCS4919)
Class – 20ITA 8
UID – 20BCS4919
SUBJECT- Web Development
DATE-04/07/2021
Ques 1: -
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
margin: 70px;
background-color: white;
</style>
</head>
<body>
<div id="demo">
</div>
<script>
function myFunction() {
document.getElementById("demo").style.backgroundColor = "red";
</script>
</body>
</html>
Output: -
BEFORE CLICKING THE BUTTON:
Code: -
<!DOCTYPE html>
<html>
<head>
<title>QUESTION 2</title>
</head>
<p id="demo"></p>
<script src="myscript1.js"></script>
<p id="demo1"></p>
<script src="myscript1.js"></script>
</body>
</html>
JAVASCRIPT CODE:
var daysInYear = 365;
var daysInWeek = 7;
var avgweek;
var greet;
function myfunction() {
document.getElementById("demo").innerHTML = avgweek;
function distime() {
else
}
}
Output: -
Ques 3: -
Write a JavaScript program where the program takes a random
integer between 1 to 10, the user is then prompted to input a guess
number. If the user input matches with guess number, the program
will display a message "Good Work" otherwise display a message
"Not matched".
Code: -
<!DOCTYPE html>
<html>
<head>
<title>QUESTION 3</title>
</head>
<p id="demo"></p>
<script src="myscript.js"></script>
JAVASCRIPT CODE:
function game(){
let a;
while ( a != 0){
alert("NOT MATCHED!!!");
alert("NOT MATCHED!!!");
alert("Good work");
break;
a++;
if (b == "Y" || b == "y"){
game();
}
Output: -
Ques 4: -
Write a JavaScript program to convert temperatures to and from
Celsius, Fahrenheit.
45°F is 7.222222222222222°C
Code: -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TEMPERATURE CONVERSION</title>
<style>
body{
background-color:white;
text-align: center;
font-size: 30px;
h2{
text-align: center;
</style>
</head>
<body>
<h2>TEMPERATURE CONVERSION</h2>
<p id="demo1"></p>
<script>
document.getElementById("demo1").innerHTML =
function tocelsius(fahrenheit){
return(5/9) * (fahrenheit-32);
</script>
<br>
<p id="demo2"></p>
<script>
document.getElementById("demo2").innerHTML =
function tofahrenheit(celsius){
return(celsius*9/5)+32;
</script>
</body>
</html>
Output: -
Ques 5: -
Write a JavaScript program to check the total marks of a student in
various examinations. The student will get A+ grade if the total marks
are in the range 89 to 100 inclusive, if the examination is "Final-exam."
the student will get A+ grade and total marks must be greater than or
equal to 90. Return true if the student gets A+ grade or false otherwise.
Code: -
<!DOCTYPE html>
<html>
<head>
<title>QUESTION 5</title>
</head>
<script src="myscript.js"></script>
</body>
</html>
JAVASCRIPT CODE:
var examination = prompt(
"Grades for exam which we need to calculate ?? \n1.) Half Yearly Exams \n2.)
Final Exams \nEnter 1 for Half Yearly Exams or 2 for Final Exams:"
);
function grade1(num) {
let grade;
if (examination == "1" || examination == 1) {
grade = "A+";
if (grade == "A+") {
return true;
} else {
return false;
grade = "A+";
if (grade == "A+") {
return true;
} else {
return false;
document.write(grade1(marks));
Output: -
Ques 6: -
Write function in js that prints prime numbers, guess secret number and
print next 20 leap years.
Code: -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Program to print prime numbers, guess secret number and print next 20
leap years.</title>
</head>
<body>
<p id="demo"></p>
<script src="myscript1.js"></script>
<script src="myscript2.js"></script>
<script type="text/Javascript">
function calcPrimeNumber()
{
while(ctr<=endNum)
if(isPrime(ctr)==true)
primeNumbs[primeNumbs.length] = ctr;
ctr = ctr+1;
if (primeNumbs.length == 0)
else
outputPrimeNums(primeNumbs);
function isPrime(num)
if((num%i)==0)
flag = false;
break;
return flag;
function outputPrimeNums(primes)
for (i=0;i<primes.length;i++){
document.getElementById('output_content').innerHTML = html;
</script>
</head>
<body>
<form name="numbers">
</form>
<div id="output_content">
</div></body>
</body>
</html>
JAVASCRIPT CODE 1:
function game() {
let a;
while (a!= 0) {
if (n < 0) {
alert("Not Matched");
alert("NOT MATCHED");
alert("Good work");
break;
a++;
if (b == "Y" || b == "y") {
game();
JAVASCRIPT CODE 2:
var year = prompt("please input a year to find out the next 20 leap years");
years = parseInt(years);
years++;
if (years % 4 === 0 && (years % 100 !== 0 || ( years % 100 === 0 && years %
400 === 0))) {
if (num === 1) {
else {
//increase years
years++;
//decrease num
num--;
else {
years++;
return "The next " + origNum + " leap years are " + leapYears;
document.write(leapyear(year, counter));
Output: -
Printing next 20 leap years
TABLE STUDENT
Code: -
<books>
<book>
<Author>R.A. Heinlein</Author>
<Publisher>Orb</Publisher>
<ISBN>0312863551</ISBN>
</book>
<book>
<title>Fahrenheit 451</title>
<Author> R.Bradbury</Author>
<Publisher>DEL RAY</Publisher>
<ISBN>0345342968</ISBN>
</book>
<book>
<title>The Silmarillion</title>
<Author>J.R.R. Tolkien</Author>
<ISBN>0048231398</ISBN>
</book>
<book>
<title>1984</title>
<Author>G. Orwell</Author>
<Publisher>Signet</Publisher>
<ISBN>0451524934</ISBN>
</book>
<book>
<title>Frankenstein</title>
<Author>M. Shelley</Author>
<Publisher>Bedford</Publisher>
<ISBN>031219126X</ISBN>
</book>
</books>