0% found this document useful (0 votes)
95 views

WEEK350

The document contains source code and outputs for 5 JavaScript programs assigned as weekly modules. The modules cover topics like identifiers, data types, operators, conditional statements, and loops. Each module lists the aim, source code, and output for programs to calculate circle area, display movie details, book movie tickets with discounts, and check for palindrome numbers.
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)
95 views

WEEK350

The document contains source code and outputs for 5 JavaScript programs assigned as weekly modules. The modules cover topics like identifiers, data types, operators, conditional statements, and loops. Each module lists the aim, source code, and output for programs to calculate circle area, display movie details, book movie tickets with discounts, and check for palindrome numbers.
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/ 7

MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

WEEK-3A
Module Name: Types of Identifiers.
Aim: To 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:
<body>
<script>
var r=parseFloat(prompt("enter radius value:")); 
const PI=3.14;
var area=PI*r*r;
document.writeln("area of circle:"+area);
</script>
</body>
Output:

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

WEEK-3B
Module Name: Primitive and Non Primitive Data Types.
Aim: To 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:
<body>
<script>
var movie=prompt("enter movie name:");
var hero=prompt("enter hero name:");
var heroine=prompt("enter heroine name:");
var rating=parseInt(prompt("enter rating"));
document.writeln(movie+"<br>");
document.writeln(hero+"<br>");
document.writeln(heroine+"<br>");
document.writeln(rating+"<br>");
</script>
</body>
Output:

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

WEEK-3C
Module Name: Operators and Types of Operators.
Aim: To 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:
<body>
<script>
var a=parseInt(prompt("enter number of tickets:"));
dis=(a*150);
document.writeln("total price is:"+dis+"<br>");
abc=dis/10
document.writeln("after 10% discount is: "+(abc)+"<br>");
document.writeln("after discount remaining amount is:"+(dis-abc));
</script>
</body>

Output:

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

WEEK-3D
Module Name: Types of Statements, Non - Conditional Statements, Types of Conditional
Statements, if Statements, switch Statements.

Aim: To 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 are above 2
less than or equal to 6, the total price should with 10% discount.

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

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

WEEK-3E
Module Name: Types of Loops.
Aim: To write a JavaScript program for the following: (a) To print the reverse of the given
number. (b) To check whether the given number is palindrome or not.
Source Code to print the numbers in given order:
<html>
<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);
}
document.writeln("Reverse of number: "+s);
</script>
</body>
</html>
Output:

Source Code for palindrome number:


<html>
<body>
<script>
var n = parseInt(prompt("Enter a number: "));
var n1=n;
var r;

SUBMITTED BY: 20KT1A4220 PAGE NO: _____


MST LAB PSCMR COLLEGE OF ENGINEERING AND TECHNOLOGY

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>
</html>
Output:

SUBMITTED BY: 20KT1A4220 PAGE NO: _____

You might also like