[go: up one dir, main page]

0% found this document useful (0 votes)
42 views10 pages

Practical Answer

The document contains 3 programming questions and their solutions - the first validates an Aadhar card number using a regular expression, the second creates 3 threads to print letters and numbers, and the third implements a stack using an array with push and pop functions in JavaScript. The solutions provided code snippets to address each question.

Uploaded by

shubham
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)
42 views10 pages

Practical Answer

The document contains 3 programming questions and their solutions - the first validates an Aadhar card number using a regular expression, the second creates 3 threads to print letters and numbers, and the third implements a stack using an array with push and pop functions in JavaScript. The solutions provided code snippets to address each question.

Uploaded by

shubham
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/ 10

STE Society’s

Sinhgad Institute of Management &

Computer Application (SIMCA)

Practical Workbook

Subject: Practical Lab

Course: MCA I - [Sem: I]

Prepared by

Shubham Bhargava

Roll No.: 20252

Seat No.: 25594


Q.1. Write the Java Script Program to validate Aadhaar Card No. using Regular Expression.
INPUT:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>JavaScript Email Validation</title>
<link rel="stylesheet" href="email.css" type="text/css" />
</head>
<body onload="document.form1.text1.focus()">
<div class="mail">
<h2>Input an Aadhar Card No.</h2>
<form name="form1" action="#">
<ul>
<li><input type="text" name="text1" /></li>
<li>&nbsp;</li>
<li class="validate">
<input
type="sub
mit"
name="val
idate"
value="Va
lidate"
onclick="ValidateEmail(document.form1.text1)"
/>
</li>
<li>&nbsp;</li>
</ul>
</form>
</div>
<script>
function ValidateEmail(input) {
var validRegex = /^[2-9]{1}[0-9]{3}\s{1}[0-9]{4}\s{1}[0-9]
{4}$/; if (input.value.match(validRegex)) {
alert("Valid Aadhar Card
No.!");
document.form1.text1.focus(
); return true;
} else {
alert("Invalid Aadhar Card
No.!");
document.form1.text1.focus(
); return false;
}
}
</script>
</body>
</html>
OUTPUT:
Q.2. Write a program that creates and run the following threads
1. To print letter ‘A’ 75 times.
2. To print letter ‘B’ 100 times.
3. To print integer 1 to 100.
INPUT:
public class Assign extends Thread

public void run()

for (int i=0; i <=75; i++)

System.out.print("A ");

System.out.println();

for (int i=0; i <=100; i++)

System.out.print("B ");

System.out.println();

for (int i=0; i <=100; i++)

System.out.print(i + " ");

public static void main(String args[])

Assign a1 = new Assign();

a1.start();

OUTPUT:
Q.3. Write a program of STACK implementation using Array with PUSH, POP operations
through JS
INPUT:
<script>

// Edit your script here

class Stack {

constructor() {

this.items = [];

push(element) {

this.items.push(element);

pop() {

return this.items.pop();

peek() {

return this.items[this.items.length - 1];

isEmpty() {

return this.items.length === 0;

size() {

return this.items.length;

clear() {

this.items = [];

toArray() {

return this.items;

disp(){
for(let i=this.items.length-1;i>=0;i--)

document.write(this.items[i]);

document.write("</br>");

toString() {

return this.items.toString();

const stack = new Stack();

document.write('stack.isEmpty() => ', stack.isEmpty());

document.write("<br>");

stack.push(66);

stack.push(77);

stack.push(88);

stack.disp();

document.write('stack.peek() => ', stack.peek());

document.write("<br>");

stack.push(90);

stack.disp();

document.write('stack.size() after push 90 => ', stack.size());

document.write("<br>");

document.write('stack.isEmpty() => ', stack.isEmpty());

document.write("<br>");

stack.push(100);

document.write('stack.size() after push 90 => ', stack.size());

document.write("<br>");

stack.disp();

stack.pop();

document.write("stack after pop </br>");


stack.disp();

stack.pop();

document.write("stack after pop </br>");

stack.disp();

document.write('stack.size() after push 100 and pop twice => ', stack.size());

</script>

OUTPUT:

You might also like