JS
JS
JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Circle Area Calculator</title>
</head>
<body>
<h1>Circle Area Calculator</h1>
<p>Enter the radius of the circle:</p>
<input type="number" id="radiusInput" placeholder="Radius">
<button onclick="calculateAndDisplayArea()">Calculate Area</button>
<div id="areaOutput"></div>
<script>
function calculateAndDisplayArea() {
let radius = document.getElementById('radiusInput').value;
const area = Math.PI * (radius ** 2);
document.getElementById('areaOutput').innerText = `The area of the circle is: ${area.toFixed(2)}`;
}
</script>
</body>
</html>
EX 3B
<!DOCTYPE html>
<html>
<head>
<title>Movie Details</title>
<style>
div#moviedesc {
height: 100px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20;
padding: 5px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 80px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
</style>
</head>
<body>
<center>
<div id="heading">Movie Details</div>
<div id="moviedesc"> </div>
<script>
//Write the code to display the movie details
var moviename="Salaar"
var language="Telugu"
var rating=5.0
let moviedesc=`Movie Name:${moviename}
<br> Language:${language}
<br> Rating:${rating}`
document.getElementById('moviedesc').innerHTML=moviedesc
</script>
</center>
</body>
</html>
EX 3C
<!DOCTYPE html>
<html>
<head>
<title>Ticket Details</title>
<style>
div#maincontent {
height: 150px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20;
padding: 5px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 80px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
h4 {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<center>
<div id="heading">
<b>Theatre Drama</b>
</div>
<div id="maincontent">
<h4>Your Ticket Details:</h4>
<br>
<script>
//Write the code to calculate the total price and discounted price for the tickets
var noOfTickets = parseInt(window.prompt("Enter number of tickets"))
document.write("Price of each ticket : $9")
document.write("<br>Number of Tickets : "+noOfTickets)
var price = noOfTickets*9
document.write("<br>Price is : "+price)
document.write("<br>10% Discount : "+price*0.1)
document.write("<br>Total Price : "+(price - (price*0.1)))
</script>
</div>
</center>
</body>
</html>
EX 3D
<!DOCTYPE html>
<html>
<head>
<title>Booking Details</title>
<style>
div#maincontent {
height: 200px;
width: 600px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20;
padding: 5px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 80px;
width: 600px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
h4 {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<center>
<div id="heading">
<b>Theatre Drama</b>
</div>
<div id="maincontent">
<h4>Your Ticket Details:</h4>
<br>
<script>
// Write the code to display the total price and discounted price of tickets
var noOfTickets = parseInt(window.prompt("Enter number of tickets"))
document.write("Price of each ticket : $9")
document.write("<br>Number of Tickets : "+noOfTickets)
var price = noOfTickets*9
if(noOfTickets<=2){
document.write("<br>Price is:$"+price)
}
else if(noOfTickets>=5){
document.write("<br>You cannot book the tickets! ")
alert("Limit exceeded")
}
else{
</script>
</div>
</center>
</body>
</html>
EX 3E
<!DOCTYPE html>
<html>
<head>
<title>Booking Details</title>
<style>
div#maincontent {
height: 200px;
width: 600px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20;
padding: 5px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 80px;
width: 600px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
h4 {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<center>
<div id="heading">
<b>Theatre Drama</b>
</div>
<div id="maincontent">
<h4>Your Ticket Details:</h4>
<br>
<script>
//Write the code to display the ticket details
let numTickets = 4;
let totalPrice = 0;
let originalPrice = 9;
let discount = ((2*i * 1)+1) % 10; // Calculate discount based on customer number
let discountedPrice = originalPrice * (1 - discount / 100);
totalPrice += discountedPrice;
document.write(`<p>Ticket for Customer ${i} gets ${discount}% discount!, Cost is: $${discountedPrice.toFixed(2)}</
}
EX 4A
<!DOCTYPE html>
<html>
<head>
<title>Booking Summary</title>
<style>
div#maincontent {
height: 250px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20;
padding: 5px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 80px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
h2 {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<center>
<div id="heading">
<h2>Booking Summary</h2>
</div>
<div id="maincontent">
<script>
const calculateDiscount = (seats) => {
if (seats <= 2) {
return 0;
} else if (seats <= 5) {
return Array(seats - 0).fill(0).map((_, i) => (2*i + 5));
} else {
return null;
}
};
const basePrice = 9;
const discountedPrice = discounts.reduce((acc, discount) => acc + basePrice * (100 - discount) / 100, 0);
return discountedPrice.toFixed(2);
};
if (discounts) {
document.write(`<p>${numSeats} seats are eligible for festive discount!!</p>`);
discounts.forEach((discount, i) => {
document.write(`<p>${discount}% discount! on Ticket ${i + 1}</p>`);
});
}
document.write(`<p>Amount payable: $${totalCost}</p>`);
</script>
</div>
</center>
</body>
</html>
EX 4B
<!DOCTYPE html>
<html lang="en">
<head>
<title>Employee Class</title>
</head>
<body>
<script>
class Person{
constructor(name, age){
this.name = name
this.age = age
}
}
class Employee extends Person{
constructor(name, age, salary, address){
super(name,age)
this.salary = salary
this.address = address
}
display(){
document.write("Name : "+this.name)
document.write("<br>Age : "+this.age)
document.write("<br>Salary : "+this.salary)
document.write("<br>Address : "+this.address)
}
}
var emp = new Employee('Nandini',21,1000000,'vizag')
emp.display()
</script>
</body>
</html>
EX 4C
<!DOCTYPE html>
<html>
<head>
<title>Booking Details</title>
<style>
div#maincontent {
height: 150px; /* Increased height to accommodate the content */
width: 500px;
border: 1px solid #CEE2FA;
text-align: left;
color: #08438E;
font-family: calibri;
font-size: 20px;
padding: 5px;
margin-left: 10px;
}
div#heading {
text-decoration: bold;
text-align: center;
margin-top: 40px;
margin-left: 10px;
width: 500px;
border: 1px solid #CEE2FA;
text-align: center;
color: #08438E;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20px;
padding: 5px;
}
h2 {
padding: 0;
margin: 0;
}
.clickable-text {
color: blue;
text-decoration: underline;
cursor: pointer;
}
</style>
</head>
<body>
<div id="heading">
<h2>Booking Summary</h2>
</div>
<div id="maincontent">
<p>Cost per ticket is: $<span id="costPerTicket">9</span></p>
<p>Total cost: $<span id="totalCost">0</span></p>
<div>
<p>
Enter the number of seats: <input type="number" id="numSeatsInput" value="4" min="1" max="5">
<button onclick="updateTotalCost()">Calculate Total Cost</button>
</p>
<p>
Congratulations! <span id="discountEl">4</span> seats are eligible for discount.
<span id="discountApply" class="clickable-text" onclick="calculateDiscount()">Apply!</span>
</p>
</div>
</div>
<script>
function calculateCost(seats) {
const costPerTicket = 9;
let totalCost = seats * costPerTicket;
if (seats > 5) {
alert("Booking is not allowed for more than 5 seats.");
totalCost = 0;
}
return totalCost;
}
function calculateDiscount() {
const discountPercentages = [0, 5, 7, 9, 11];
const discountEl = document.getElementById("discountEl");
const totalCostEl = document.getElementById("totalCost");
const amountPayableEl = document.getElementById("amountPayable");
totalCostEl.textContent = totalCost.toFixed(2);
function updateTotalCost() {
const numSeatsInput = document.getElementById("numSeatsInput");
const numSeats = parseInt(numSeatsInput.value);
const costPerTicketEl = document.getElementById("costPerTicket");
const totalCostEl = document.getElementById("totalCost");
EX 4D
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Enjoy Your Ice Cream!</title>
<style>
body {
background-color: lightblue;
text-align: center;
font-family: sans-serif;
}
#ice-cream-container {
margin: 50px auto;
width: 400px;
border: 1px solid #ccc;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
h1 {
margin-bottom: 20px;
}
#ice-cream-image {
width: 400px;
height: 300px;
border-radius: 10px;
}
#ice-cream-message {
margin-top: 20px;
font-size: 16px;
}
#eat-button {
padding: 10px 20px;
border: none;
background-color: #4CAF50;
color: white;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="ice-cream-container">
<h1>Scrumptious Ice Cream Cone!</h1>
<img id="ice-cream-image" src="./Ice 1.jpg" alt="Ice cream cone filled with scoops">
<p id="ice-cream-message">Ready to enjoy this delicious treat?</p>
<button id="eat-button" onclick="eat()">Click here to eat!</button>
</div>
<script>
let clicks = 0;
function eat() {
clicks++;
if (clicks === 1) {
document.getElementById("ice-cream-image").src ="./Ice2.1.jpg";
EX 5A
<!DOCTYPE html>
<html>
<head>
<title>Movies</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div style="margin-top:7%">
<center>
<h2>Your Favorite Movies!!</h2>
</center>
</div>
<div class="container" style="padding-top:5%">
<div class="row">
<div class="col-md-4">
<div style="text-align: center;">
<img src="./FourSoldiers.jpg" width="200px" height="250px">
</div>
<div style="padding-top:10px;">
<div style="text-align: center; ">
<b><span id="mName0"></span></b></div>
<div style="padding-top:10px;padding-left: 101px;"><b>Language: </b><span id="lang0"></span>
</div>
<div style="padding-left: 100px;"><b>Rating: </b><span id="rating0"></span></div>
</div>
</div>
<div class="col-md-4">
<div style="text-align: center;">
<img src="./Tomorrowland.jpg" width="200px" height="250px">
</div>
<div style="padding-top:10px;">
<div style="text-align: center; "><b><span id="mName1"></span></b></div>
<div style="padding-top:10px;padding-left: 95px;"><b>Language: </b><span id="lang1"></span>
</div>
<div style="padding-left: 94px;"><b>Rating:</b><span id="rating1"></span></div>
</div>
</div>
<div class="col-md-4">
<div style="text-align: center;">
<img src="./HungerGames.jpg" width="200px" height="250px">
</div>
<div style="padding-top:10px;">
<div style="text-align: center; "><b><span id="mName2"></span></b></div>
<div style="padding-top:10px;padding-left: 118px;"><b>Language: </b><span id="lang2"></span>
</div>
<div style="padding-left: 117px;"><b>Rating:</b><span id="rating2"></span></div>
</div>
</div>
</div>
</div>
</body>
<script>
//Write the code here
//Movie data as an array of objects
const movies = [
{
name: "The Four Soldiers",
language: "English",
rating: 3.1
},
{
name: "Tomorrowland: A World Beyond",
language: "English",
rating: 3.2
},
{
name: "The Hunger Games",
language: "English",
rating: 3.6
}
];
EX 5B
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Price Simulator</title>
</head>
<body>
<script>
// Function to generate a random rounded number
function generateRandomNumber() {
return Math.floor(Math.random() * 100); // Generating random number between 0 and 99
}
// Start simulation
simulateStockPriceUpdates().then((message) => {
document.write(message);
}).catch((error) => {
console.error("Error:", error);
});
</script>
</body>
</html>
EX 5C
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
</head>
<body>
<h2>Login</h2>
<form onsubmit="validateLogin()">
<label for="username">Username:</label>
<input type="text" id="username" required>
<label for="password">Password:</label>
<input type="password" id="password" required>
<button type="submit">Login</button>
</form>
<script>
// Import the User class from login.js
class User {
constructor(username, password) {
this.username = username;
this.password = password;
}
validate(inputUsername, inputPassword) {
if (inputUsername === this.username && inputPassword === this.password) {
return "Login Successful";
} else {
return "Unauthorized access";
}
}
}
// Create an instance of the User class with your desired username and password
const user = new User("exampleUser", "examplePassword");
alert(result);