Exercise-3 MST Programs
Exercise-3 MST Programs
3.(a)
Course Name: JavaScript
Module Name: Type of Identifiers
AIM: Write a JavaScript program to find the area of a circle using radius (var and let –
reassign and observe the difference with var and let) and PI (const)
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Area of Circle</title>
<style>
.mydiv{
height: 200px;
width: 700px;
border: 2px solid blue; text-align: center;
color: red;font-size:30px;
font-family: verdana; padding-top: 90px;
}
</style>
</head>
<body>
<center>
<br><br><br><br>
<h1>Find the Area of Circle</h1>
<div class="mydiv">
<script>
var radius, Area ;
const pi=3.14;
radius=prompt("Enter the Radius");
Area=pi *radius *radius;
document.write("Area of Circle is: " + Area);
</script>
</div>
</center>
</body>
</html>
3(a) OUTPUT
3.(b)
Course Name: JavaScript
Module Name: Primitive and Non Primitive Data Types
AIM: Write JavaScript code to display the movie details such as movie name, starring,
language, and ratings. Initialize the variables with values of appropriate types. Use
template literals wherever necessary.
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Movie Details</title>
<style>
.mydiv{
height: 400px;
width: 900px;
border: 2px solid purple;
text-align: left;
color: blue;
font-size:30px;
font-family: verdana;
padding-top: 60px;
}
</style>
</head>
<body bgcolor="white">
<center>
<br><br><br><br>
<h1><b>Display Movie Details </h1>
<div class="mydiv">
<script type ="text/javascript">
let Movie='SALAAR';
let Starring='Prabhas,Prithviraj,ShrutiHaasan,<br> Jagapathi
Babu,Easwari,Jhansi';
let Director="Prashanth Neel";
let Musician ='Ravi Basrur';
let Producer='Vijay Kirgandur';
var Language=["Telugu","Tamil","Kannada","Malayanam","Hindi"]; // Array initialization
var Rating= 6.6;
document.write(" Movie :", Movie);
document.write(" Starring :", Starring);
document.write(" Director :", Director);
document.write(" <br>Musician :", Musician);
document.write(" <br>Producer :",Producer);
document.write(" Language :",Language);
document.write(" Rating :",Rating);
</script>
</div>
</center>
</body>
</html>
3(b) OUTPUT:
3.(c)
Course Name: JavaScript
Module Name: Operators and Types of Operators
AIM: Write JavaScript code to book movie tickets online and calculate the total price,
considering the number of tickets and price per ticket as Rs. 150. Also, apply a festive
season discount of 10% and calculate the discounted amount.
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Ticket Details</title>
<style>
.mydiv {
text-decoration: bold;
text-align: left;
margin-top: 80px;
width: 500px;
border: 1px solid purple;
text-align: center;
color: blue;
background-color: #CEE2FA;
font-family: calibri;
font-size: 20;
padding: 5px;
}
</style>
</head>
<body bgcolor="pink">
<div class="mydiv">
<h1><b>Theatre Mohan, Chirala</h1>
<h4>Your Ticket Details:</h4>
</div>
<h2> <font color="red">
<script type="text/javascript">
// to calculate the total price and discounted price for the tickets
var currentDate = new Date();
let ticket = prompt("Enter the Ticket Price");
let seats = prompt("Enter Number of Tickets: ");
let total_cost = seats*150;
let discount = (total_cost*10)/100;
document.write(currentDate);
document.write("<br>The number of seats booked: " +seats);
document.write(" <br>Price per Ticket : "+"Rs."+ticket);
document.write("<br>Total Cost of " + seats + "Tickets:"+"Rs."+total_cost);
document.write("<br>Festive Season Discount is: 10% ");
document.write(" <br>Discounted Amount: "+"Rs."+discount);
document.write(" <br>Total Cost after Discount is: "+"Rs."+(total_cost-discount));
</script>
</h2>
</body>
</html>
3(c) OUTPUT:
3(d):
Course Name: JavaScript
Module Name: Types of Statements, Non - Conditional Statements, Types of Conditional
Statements, if Statements, switch Statements
AIM: Write a JavaScript code to book movie tickets online and calculate the total price
based on the 3 conditions: (a) If seats to be booked are not more than 2, the cost per ticket
remains Rs. 150. (b) If seats are 6 or more, booking is not allowed. (c) If seats to be booked
are more than 2 but less than 5, based on the number of seats booked. (festive season
discount of 10% )
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Booking Details</title>
<style>
.mydiv {
text-decoration: bold;
text-align: left;
margin-top: 5px;
width: 1200px;
border: 1px solid purple;
text-align: center;
color: blue;
background-color: pink;
font-family: verdana;
font-size: 15;
padding: 5px;
}
</style>
</head>
<body>
<center>
<h1 style="color:red;font-size:40;"><b>Theatre Mohan, Chirala</b>
<div class="mydiv">
<h4>Your Ticket Details:</h4>
<script>
var tp = 150;
var seats=prompt("Enter the number of Seats");
var totalcost = tp * seats;
document.write("<br>The number of seats booked: " +seats);
document.write("<br>Total Cost :Rs."+totalcost);
var discount = (totalcost *10)/100
if (seats <=2)
{
document.write('<br>The cost per '+seats+ ' ticket(s) Rs: '+totalcost);
}
if (seats >= 6)
{
document.write('<br>Booking is not allowed for 6 or more tickets');
}
3(d) OUTPUT:
3(e):
Course Name: JavaScript
Module Name: Types of Loops
AIM: Write a JavaScript code to book movie tickets online and calculate the total price
based on the 3 conditions: (a) If seats to be booked are not more than 2, the cost per ticket
remains Rs. 150. (b) If seats are 6 or more, booking is not allowed. (c) If seats to be booked
are more than 2 but less than 5, based on the number of seats booked.
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<title>Booking Details</title>
<style>
.mydiv {
text-decoration: bold;
text-align: left;
margin-top: 5px;
width: 1200px;
border: 1px solid purple;
text-align: center;
color:red;
background-color: #c7f15e;
font-family: Arial;
font-size: 15;
padding: 5px;
}
</style>
</head>
<body>
<center>
<h1 style="color:blue;font-size:60;"><b>Theatre Mohan, Chirala</b>
<div class="mydiv">
<h4>Your Ticket Details:</h4>
<script>
let tp = 150; // ticket price
var seats=prompt("Enter the number of Seats");
var totalcost = tp * seats;
document.write("<br>The number of seats booked: " +seats);
document.write("<br>Total Cost :Rs."+totalcost);
if (seats <=2)
{
document.write('<br>The cost per '+seats+ ' ticket(s) Rs: '+totalcost);
}
else if (seats >= 6)
{
document.write('<br>Booking is not allowed for 6 or more tickets');
}
if ( seats> 2 && seats < 5)
{
//Array initialization
let d = [5, 9, 11, 13]; // discount for customers
let c1 = tp - (tp * 5) / 100;
let c2 = tp - (tp * 9) / 100;
let c3 = tp - (tp * 11) / 100;
let c4 = tp - (tp * 13) / 100;
let C = [c1, c2, c3, c4];
let count = 0;
let sum = 0;
for (let i = 0; i< seats; i++)
{
count++;
document.write(`<br>Ticket for customer ${count} gets ${d[i]} % discount!, Cost is Rs : $
{C[i]}<br>`);
sum = sum + C[i];
}
document.write(`<br>For `+seats+` tickets ,you need to pay : Rs. ${sum}, instead of Rs. ${tp *
seats}`);
}
</script>
</div>
</center>
</body>
</html>
3(e) OUTPUT: