0% found this document useful (0 votes)
77 views9 pages

MST Word Format

The document contains source code and outputs from JavaScript programs written for a weekly lab assignment. The programs cover topics like data types, operators, conditional statements, loops and more. Each section provides the aim of the program, source code, and screenshots of the output for programs related to finding the area of a circle, displaying movie details, applying discounts, booking movie tickets with conditions, and checking if a number is a palindrome.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views9 pages

MST Word Format

The document contains source code and outputs from JavaScript programs written for a weekly lab assignment. The programs cover topics like data types, operators, conditional statements, loops and more. Each section provides the aim of the program, source code, and screenshots of the output for programs related to finding the area of a circle, displaying movie details, applying discounts, booking movie tickets with conditions, and checking if a number is a palindrome.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

MST LAB PSCMR college of Engineering and Technology

WEEK 3A
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 for var program:

<body>

<script>

const pi=3.14;

var r=parseFloat(prompt("enter a radius values:"));

document.writeln("Area of the Circle:"+(pi*r*r));

</script>

</body>

Output:

Fig: Output for radius value

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

Fig: Output for the area of the circle

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

WEEK 3B
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 for movie details:

<body>

<script>

var mov=prompt("movie name:");

var star=prompt("starring:");

var rat=prompt("rating:");

var lan=prompt("language:");

document.writeln("<br>movie name:"+mov);

document.writeln("<br>starring name:"+star);

document.writeln("<br>rating:"+rat);

document.writeln("<br>language:"+lan);

</script>

</body>

Output

Fig: Output for the display of the movie details

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

WEEK 3C
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 for discount:

<body>

<script type="text/javascript">

var tick = parseInt(prompt("Enter no.of tickets"));

var tot= tick*150;

var dis=(tot*10)/100;

document.write("Total Amount"+tot+'<br>');

document.write("Total Amount After Discount"+(tot-dis));

</script>

</body>

Output:

Fig: Output for no.of tickets

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

Fig: Output for the discount amount

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

WEEK 3D

Module Name: Types of Statement, Non-Conditional Statement, 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 the 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 seated are about to
less or equal to 6 the total price should to with 10% discount.

Source code:

<html>
<body>
<script>
var n = parseInt(prompt("Enter no.of tickets"));
var totalprice,discount,price;
if((n>0) && (n<=2))
{
totalprice=n*150;
document.writeln("please pay money:Rs",+totalprice+"/");
}
else if((n>2) && (n<=6))
{
price=n*150;
discount=(10*price)/100;
totalprice=price-discount;
document.writeln("please pay money:Rs",+totalprice+"/");
}
else
{
document.writeln("please we can't booking ticket");
}
</script>
</body>
</html>

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

Output:

Figs: Output fr Booking tickets for Movi

Figs: Output for not Booking tickets for Movie

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

WEEK 3E
Module Name: Types of loops

Aim: Write a javascript program for t following a) To print the reverse of the given number.

b) to check given number is a paralleldrum or not.

Source code for reverse number:


<html>
<body>
<script>
var n = parseInt(prompt("Enter a number:")); var
r,sum = 0;
while(n!=0)
{
r = n%10;
sum=sum*10+r;
n = parseInt(n/10);
}
document.writeln("reverse of the numbers:"+sum+"<br>");
</script>
</body>
</html>

Fig: Output for reverse number

Submitted by: 20KT1A4239 Page No.


MST LAB PSCMR college of Engineering and Technology

Source code for Palindrome:


<body>
<script>
var n = parseInt(prompt("Enter a number: "));
var n1=n;
var r;
var s=0;
while(n!=0)
{
r = n%10;
s = s*10+r;
n =parseInt(n/10);

}
if(n1==s)
{document.writeln("<br>Number is a palindrome ");}
else{document.writeln("<br>Number is not a palindrome ");}
</script>
</body>

Output:

Fig: Output for palindrome

Submitted by: 20KT1A4239 Page No.

You might also like