Download - Aps and Jwt Lab Manual
![Page 1: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/1.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
1) AIM: Write a program for stack using linked list
PROGRAM:
#include<iostream.h>#include<conio.h>#include<stdio.h>#include<malloc.h>struct chainnode{ int item; chainnode *next;};class stacklist{ private: struct chainnode *top; int listsize; public:
stacklist() { listsize=0; } int asizeof() { return(listsize); }
int push(int element){
struct chainnode *temp; temp=new chainnode ; if(!temp) return(0); temp->item=element; temp->next=top; top=temp; listsize++; return(1);
Page 1
![Page 2: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/2.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
}int pop(){ if(top==NULL) { cout<<"\n stack emty"; return 0; } else { struct chainnode *temp; temp=top; top=top->next;
temp->next=NULL; cout<<"\nthe poped element is:"<<temp->item;
free(temp); listsize--; return(1); }}void display(){ int i; struct chainnode *temp; temp=top; for(i=1;i<=listsize;i++) {
cout<<"\n item : "<<temp->item; temp=temp->next; } return;}~stacklist(){ int i; struct chainnode *temp; for(i=1;i<=asizeof();i++) { temp=top; top=top->next;
Page 2
![Page 3: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/3.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
free(temp); }}
};void main(){ stacklist t; char a; int i,p,q; clrscr(); do { cout<<"\n"<<"1.insert"<<"\n"<<"2.delete"<<"\n"<<"3.sizeof list"<<"\n"<<"4.display"<<"\n"; cout<<"enter number u want:"; cin>>i; switch(i) { case 1: cout<<"\nenter the item: ";
cin>>q; if(t.push(q)) cout<<"\nsucess"; else cout<<"\nfailed"; break;
case 2:if(t.pop()) cout<<"\nsucess"; else cout<<"\nfailed"; break;
case 3:cout<<"\nthe size of list is :"<<t.asizeof(); break;
case 4:t.display(); break;
default:cout<<"\nwrong entry try again"; break;
} cout<<"\ndo you want to continue:(y/n)"; cin>>a;
Page 3
![Page 4: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/4.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
}while(a=='y'); getch();}
OUTPUT:
1.insert2.delete3.size of list4.displayenter number u want:1
enter the item: 23
sucessdo you want to continue:(y/n)y
1.insert2.delete3.size of list4.displayenter number u want:1
enter the item: 40
sucessdo you want to continue:(y/n)y
1.insert2.delete3.size of list4.displayenter number u want:2
the poped element is:40sucessdo you want to continue:(y/n)y
1.insert2.delete
Page 4
![Page 5: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/5.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
3.size of list4.displayenter number u want:3
the size of list is :1do you want to continue:(y/n)n
2) AIM: Write a program for queue using linked list
PROGRAM:
#include<iostream.h>#include<conio.h>#include<stdio.h>#include<malloc.h>struct chainnode{ int item; chainnode *next;};class queuelist{ private: struct chainnode *front,*rare; int listsize;
Page 5
![Page 6: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/6.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
public: queuelist() { listsize=0; } int asizeof() { return(listsize); }
int insert(int element){
struct chainnode *temp; temp= new chainnode ; if(!temp) return(0); if(listsize==0) { temp->item=element; temp->next=NULL; front=temp; rare=temp; listsize++; } else { temp->item=element; temp->next=NULL; front->next=temp; front=temp; listsize++; return(1); } }int deletel(){ if( rare==NULL) { cout<<"\n queue emty";
Page 6
![Page 7: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/7.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
return 0; } else { struct chainnode *temp; temp=rare; rare=rare->next;
temp->next=NULL cout<<"\nthe poped element is:"<<temp->item;
free(temp); listsize--; return(1); }}void display(){ int i; struct chainnode *temp; temp=rare; for(i=1;i<=listsize;i++) {
cout<<"\n item : "<<temp->item; temp=temp->next; } return;}~queuelist(){ int i; struct chainnode *temp; for(i=1;i<=asizeof();i++) { temp=rare; rare=rare->next; free(temp); }}
};void main(){
Page 7
![Page 8: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/8.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
queuelist t; char a; int i,p,q; clrscr(); do { cout<<"\n"<<"1.insert"<<"\n"<<"2.delete"<<"\n"<<"3.size of list"<<"\n"<<"4.display"<<"\n"; cout<<"enter number u want:"; cin>>i; switch(i) { case 1: cout<<"\nenter the item: ";
cin>>q; if(t.insert(q)) cout<<"\nsucess"; else cout<<"\nfailed"; break;
case 2:if(t.deletel()) cout<<"\nsucess"; else cout<<"\nfailed"; break;
case 3:cout<<"\nthe size of list is :"<<t.asizeof(); break;
case 4:t.display(); break;
default:cout<<"\nwrong entry try again"; break;
} cout<<"\ndo you want to continue:(y/n)"; cin>>a; }while(a=='y'); getch();}
OUTPUT:
Page 8
![Page 9: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/9.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
1.insert2.delete3.size of list4.displayenter number u want:1
enter the item: 32
sucessdo you want to continue:(y/n)y
1.insert2.delete3.size of list4.displayenter number u want:1
enter the item: 67
sucessdo you want to continue:(y/n)y
1.insert2.delete3.size of list4.displayenter number u want:2
the poped element is:32sucessdo you want to continue:(y/n)y
1.insert2.delete3.size of list4.displayenter number u want:2
the poped element is:67sucess
Page 9
![Page 10: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/10.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
do you want to continue:(y/n)n
3)AIM: Write a program for implementing Binary search.
PROGRAM:
#include<iostream.h>#include<conio.h>
void main(){ int a[20],n,mid,f,l,c,flag=0,x; clrscr(); cout<<"Enter the size of the array:"; cin>>n; cout<<"\nEnter the elements in ascending order:"; for(c=0;c<n;c++) cin>>a[c]; cout<<"\nEnter the searching element:\n"; cin>>x; c=0;f=0;l=n; while((flag==0)&&(c<n)) { mid=(f+l)/2; if(a[mid]>x) l=mid-1; else if(a[mid]<x) f=mid+1; else flag=1; c=c+1; } if(flag==1) cout<<"Element is found at "<<mid+1<<"place"; else cout<<"Element is not found......"; getch(); }
Page 10
![Page 11: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/11.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Enter the size of the array:5
Enter the elements in ascending order:234567898
Enter the searching element:78Element is found at 4 place
4) AIM: Write a program for mergesort.
PROGRAM:
Page 11
![Page 12: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/12.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
#include<iostream.h>#include<conio.h>int a[50];void merge(int,int,int);void merge_sort(int low,int high){ int mid; if(low<high) { mid=(low+high)/2; merge_sort(low,mid); merge_sort(mid+1,high); merge(low,mid,high); }}void merge(int low,int mid,int high){ int h,i,j,b[50],k; h=low; i=low; j=mid+1;
while((h<=mid)&&(j<=high)) { if(a[h]<=a[j]) { b[i]=a[h]; h++; } else { b[i]=a[j]; j++; } i++; } if(h>mid) { for(k=j;k<=high;k++) {
Page 12
![Page 13: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/13.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
b[i]=a[k]; i++; } } else { for(k=h;k<=mid;k++) { b[i]=a[k]; i++; } } for(k=low;k<=high;k++) a[k]=b[k];}void main(){ int num,i; clrscr();
cout<<endl<<endl; cout<<"Please Enter THE NUMBER OF ELEMENTS you want to sort [THEN PRESS ENTER]:"<<endl; cin>>num; cout<<endl; cout<<"Now, Please Enter the ( "<< num <<" ) numbers (ELEMENTS) [THEN PRESS ENTER]:"<<endl; for(i=1;i<=num;i++) { cin>>a[i] ; } merge_sort(1,num); cout<<endl; cout<<"So, the sorted list (using MERGE SORT) will be :"<<endl; cout<<endl<<endl;
for(i=1;i<=num;i++) cout<<a[i]<<" ";
cout<<endl<<endl<<endl<<endl;getch();
Page 13
![Page 14: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/14.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
}
OUTPUT:
Please Enter THE NUMBER OF ELEMENTS you want to sort [THEN PRESS ENTER]:5
Now, Please Enter the ( 5 ) numbers (ELEMENTS) [THEN PRESS ENTER]:235611930
So, the sorted list (using MERGE SORT) will be :
9 11 23 30 56
5) AIM: Write a program for Quick sort
PROGRAM:
#include<iostream.h>#include<conio.h>#include<process.h>class Qsort{int *a;int n;public: Qsort(int size){n=size;
Page 14
![Page 15: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/15.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
a=new int[n];}void read();void display();void qsort(int left, int right);};
void Qsort::read(){cout<<"\nEnter elements";for(int i=0;i<n;i++)cin>>a[i];}
void Qsort::display(){for(int i=0;i<n;i++)cout<<a[i]<<"\t";}
void Qsort::qsort(int left, int right){int pivot=a[left];int l=left,r=right;while(l<r){while(a[r]>=pivot&&l<r)r--;if(l!=r)a[l]=a[r];while(a[l]<=pivot&&l<r)l++;if(l!=r)a[r]=a[l];a[l]=pivot;}pivot=l;if(left<pivot)qsort(left,pivot-1);if(right>pivot)qsort(pivot+1,right);}void main(){clrscr();Qsort q(10);q.read();
Page 15
![Page 16: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/16.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
cout<<"\nBefore sorting:\n";q.display();q.qsort(0,9);cout<<"\nAfter sorting:\n";q.display();getch();}
OUTPUT:
Enter elements90 10 80 20 40 50 1 2 3 5
Before sorting:90 10 80 20 40 50 1 2 3 5
After sorting:1 2 3 5 10 20 40 50 80 90
Page 16
![Page 17: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/17.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
6) AIM: Write a program for Selection sort
PROGRAM:
#include<iostream.h>#include<conio.h>void main(){ int a[20],i,n; void selectionsort(int[],int) clrscr(); cout<<"enter number of elements:\n"; cin>>n; cout<<"enter elements"; for(i=0;i<n;i++) cin>>a[i]; selectionsort(a,n); cout<<"after sorting elements are\n"; for(i=0;i<n;i++) cout<<a[i]<<endl; getch();}void selectionsort(int x[],int n){ int i,j,temp,mp; for(i=0;i<n-1;i++) { mp=i; for(j=i+1;j<n;j++) { if(a[j]<a[mp]) mp=j; } if(i!=mp) { temp=a[i]; a[i]=a[mp]; a[mp]=temp; } } }
Page 17
![Page 18: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/18.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Enter number of elements5Enter elements 16 12 5 47 2After sorting elements are25121647
Page 18
![Page 19: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/19.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
7) AIM: Write a program for insertion sort
PROGRAM:
#include<iostream.h>#include<conio.h>void main(){ int i,n,j,p,q; int t[100]; clrscr(); cout<<"Enter how many numbers u want to sort \n"; cin>>n; p=0; cout<<"Enter the values \n"; for(i=0;i<n;i++) cin>>t[i]; for(i=1;i<n;i++) { q=t[i]; j=i-1; do { if(t[j]>q) { t[j+1]=t[j]; j=j-1; if(j<0) break; } else break;
}while(1); t[j+1]=q;
} cout<<"the sorted order is :\n"; for(i=0;i<n;i++) cout<<t[i]<<"\n"; getch();
Page 19
![Page 20: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/20.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
}
OUTPUT:
Enter how many numbers u want to sort5Enter the values211190459the sorted order is :911214590
8)AIM: Write a program for implementation of prims algorithm PROGRAM:
#include<iostream.h>#include<conio.h>void main(){
Page 20
![Page 21: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/21.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
int min=0,pnear[10],n=7,j,p,i,k,l,min1,o; int c[100][100]; int t[100][2]; clrscr(); cout<<"Enter number of nodes:"; cin>>n; cout<<"\nEnter the cost for following edge/nIf edge is not there put:-1\n" ; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { cout<<"("<<i+1<<","<<j+1<<") :"; cin>>c[i][j]; c[j][i]=c[i][j]; cout<<"\n"; } t[i][0]=t[i][1]=c[i][i]= -1; } for(i=0;i<n;i++) pnear[i]=0; pnear[0]=-1; for(i=0;i<n-1;i++) { min1=999; for(l=0;l<n;l++) { if(pnear[l]==-1 || c[l][pnear[l]]==-1) { continue; } else { if(c[l][pnear[l]]<min1) { min1=c[l][pnear[l]]; t[i][0]=l; t[i][1]=pnear[l]; } } } min=min+min1;
Page 21
![Page 22: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/22.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
pnear[p=t[i][0]]=-1; for(j=0;j<n;j++) { o=pnear[j]; if(o!=-1 ) { if(c[j][o]==-1 || c[j][p]==-1) { if(c[j][o]==c[j][p]==-1) continue; if(c[j][o]==-1) pnear[j]=p; continue; } if(c[j][o]>c[j][p]) pnear[j]=p; } }} cout<<"\nMin cost is :"<<min; cout<<"\n the edges are:"; for(i=0;i<n;i++) { if(t[i][0]==-1) continue; cout<<"\n("<<t[i][0]+1<<","<<t[i][1]+1<<") "; } getch();}
OUTPUT:
Enter number of nodes:4
Enter the cost for following edge/nIf edge is not there put:-1(1,2) :21
(1,3) :-1
(1,4) :4
Page 22
![Page 23: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/23.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
(2,3) :4
(2,4) :-1
(3,4) :5
Min cost is :13 the edges are:(4,1)(3,4)(2,3)
9) AIM: Write a program for implementation of BFS (Breadth First Search)
PROGRAM:
#include<iostream.h>#include<conio.h>class bfs{int v,u,n,i,j,str;int gra[20][20],visited[20];public: bfs(){}void bfs1(int);void bft();void input();int adj(int,int);};void bfs::input(){cout<<"\nEnter the number of nodes\n";cin>>n;
Page 23
![Page 24: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/24.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
cout<<"\nEnter the adjcency matrix\n";for(i=1;i<=n;i++)for(j=1;j<=n;j++)cin>>gra[i][j];
}int bfs::adj(int a,int b){if(gra[a][b]==1)return 1;elsereturn 0;}void bfs::bft(){for(i=1;i<=n;i++)visited[i]=0;for(i=1;i<=n;i++)if(visited[i]==0)bfs1(i);}void bfs::bfs1(int v){int q[20],front=0,rear=0;u=v;visited[v]=1;cout<<v<<"\t";while(1){for(int w=1;w<=n;w++){if(adj(u,w)==1&&visited[w]==0){q[rear]=w;rear++;cout<<w<<"\t";visited[w]=1;}}if(front>rear)return;
Page 24
![Page 25: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/25.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
else{u=q[front];front++;}}}void main(){clrscr();bfs b;b.input();cout<<"BFT is\n";b.bft();getch();}
OUTPUT:
Enter the number of nodes3
Enter the adjcency matrix1 0 11 0 11 0 0BFT is1 3 2
Page 25
![Page 26: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/26.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
10) AIM: Write a program for implementation of DFS (Depth First Search)
PROGRAM:
#include<iostream.h>#include<conio.h>class dfs{int i,j,k,n;int gra[20][20],visited[20];public: dfs(){}void dfs1(int);void dft();void input();int adj(int,int);};void dfs::input(){cout<<"\nEnter the number of nodes\n";cin>>n;cout<<"\nEnter the adjcency matrix\n";for(i=1;i<=n;i++)for(j=1;j<=n;j++)cin>>gra[i][j];}int dfs::adj(int a,int b){if(gra[a][b]==1)return 1;elsereturn 0;}void dfs::dft(){for(i=1;i<=n;i++)visited[i]=0;for(i=1;i<=n;i++)if(visited[i]==0)dfs1(i);}void dfs::dfs1(int v)
Page 26
![Page 27: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/27.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
{int w;visited[v]=1;cout<<v<<"\t";for(w=1;w<=n;w++){if(visited[w]==0&&adj(v,w)==1){dfs1(w);}}}void main(){clrscr();dfs d;d.input();cout<<"DFT is\n";d.dft();getch();}
OUTPUT:
Enter the number of nodes4Enter the adjcency matrix1 0 1 00 1 0 11 0 1 00 0 0 1DFT is1 3 2 4 11)AIM : Write a HTML program to implement list
PROGRAM:
<html><head><title>Mega Shop</title></head>
Page 27
![Page 28: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/28.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
<body><h2>Two simple lists</h2><h3>Products</h3><ul><li>Widgets, sizes 2 to 12</li><li>ThingummyBobs for families and the single person</li></ul><h3>Deadlines</h3><ol><li>Place your orders before 4 pm for next day delivery</li><li>Order by midnight for next new year</li></ol><h3>And a definition list</h3><dl><dt><a href="example2.html">Widget</a></dt><dd>Provided in three sizes <i>small,medium,large</i>,and a range of colors.</dd><dt><a href="example2.html">Thingummybobs</a></dt><dd>Just what home needs. Now available in teal and cerise stripes for the new season.</dd></dl></body></html>
Page 28
![Page 29: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/29.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
12) AIM: Write a HTML program to implement Timetable
PROGRAM:
Page 29
![Page 30: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/30.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
<html><head><title> M.tech time table</title></head><body><h1> <center>M.tech I year I sem time table </center></h1><table border="1" align= "center"><tr> <th></th> <th>9.40AM - 11.20AM</th> <th>11.20AM - 1.00PM</th> <th>1.00PM - 2.00PM</th> <th>2.00PM - 3.40PM</th> <th>3.40PM - 5.20PM</th> </tr><tr><th>MOnday</th><td>HSN</td><td>APS</td><td rowspan="5"><center>Lunch</center></td><td>CSD</td></tr><tr><th>Tuesday</th><td>IRS</td><td>JAVA&WT</td><td colspan="5"><center>JAVA&WT lab</center></td></tr><tr><th>Wednesday</th><td>IRS</td><td>JAVA & WT</td><td>CSD</td></tr><tr><th>Thursday</th><td colspan="2"><center>APS lab</center></td><td>ADW</td></tr><tr>
Page 30
![Page 31: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/31.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
<th>Friday</th><td>APS</td><td>HSN</td><td>ADM</td></tr></table></body></html>
Page 31
![Page 32: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/32.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 32
![Page 33: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/33.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
13) AIM: Write a HTML program to implement form.
PROGRAM:
<html><head><title>form creation</title></head><body><center> <form action="orderedlist.html " method="post"> <h1 align="center">Registration form</h1> Username:<input type="text" name="user"><br><br> Password:<input type="text" name="pwd"><br><br> Confirm password:<input type="text" name="pwd1"><br><br> Address:<textarea rows="2" cols="5"></textarea><br> <input type="radio" name="sex" value="male"/>Male <input type="radio" name="sex" value="female"/>Female<br> <input type="checkbox" name="vechile" value="bike"/>I have a bike<br> <input type="checkbox" name="vechile" value="car"/>I have a car<br> <input type="submit" name="submit" value="submit"> <input type="reset" name="submit" value="Reset"<br></center> </form> </body></html>
Page 33
![Page 34: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/34.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 34
![Page 35: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/35.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
14) AIM: Write a HTML program to implement inline style sheets internal style sheets and external style sheets
PROGRAM:
<html><head><title>inlinestylesheets</title></head><body ><p style="color:blue;margin-left:20px ;font-family:sans-serif; font-weight:bold"> this passage has an effect of css rules supplied by p selector using style attribute</p><br><p>this passage is not under the influence of css rules specified</p></body></html>
Page 35
![Page 36: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/36.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 36
![Page 37: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/37.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
internal style sheets
PROGRAM:
<html> <head> <title> internalstylesheets</title> <style type="text/css"> h1{font-family:sans-serif;color:green;text-align:center;font-size:30;} p{font-family;font-size:15;font-weight:bold;} body{background:yellow;} </style> </head><body> welcome<p>this passage has an effect of css rules supplied by p selector in head region</p><h1>hello</h1></body></html>
Page 37
![Page 38: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/38.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 38
![Page 39: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/39.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
external style sheets
PROGRAM:
<html> <head> <title> external stylesheets</title> <link rel="stylesheets" type="text/css" href="C:\Documents and Settings\Desktop\labprograms\rules.css"> </head><body> welcome<p>this passage has an effect of css rules supplied by p selector in head region</p><h1>hello</h1></body></html>
Page 39
![Page 40: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/40.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 40
![Page 41: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/41.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
15)AIM: Write a JAVASCRIPT program to implement calculator
PROGRAM:
<html><head><title> Calculator </title><script type="text/javascript">var a,b,c;function read(){
a = parseInt(document.getElementById('num1').value);b = parseInt(document.getElementById('num2').value);verify();
}function verify(){
if(a<0 || b<0){
alert("Please enter positive numbers only");clear();exit();
}
}function add(){
read();c = a+b;document.getElementById('res').value=c;
}function sub(){
read();c = a-b;document.getElementById('res').value=c;
}function mul(){
Page 41
![Page 42: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/42.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
read();c = a*b;document.getElementById('res').value=c;
}function div(){
read();c = a/b;document.getElementById('res').value=c;
}function mod(){
read();c = a%b;document.getElementById('res').value=c;
}function clear(){
document.getElementById('num1').value="";document.getElementById('num2').value="";document.getElementById('res').value="";
}</script></head><body onload="clear()">
<form method="post">First Number : <input type='text' id='num1' size='5'/>
<br>Second Number : <input type='text' id='num2' size='5'/>
<br>Result : <input type='text' id='res' size='5' readonly />
<br><input type='button' onclick='add()' value='Add' /><input type='button' onclick='sub()' value='Sub' /><input type='button' onclick='mul()' value='Mul' /><input type='button' onclick='div()' value='Div' /><input type='button' onclick='mod()' value='Mod' />
</form></body>
</html>
Page 42
![Page 43: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/43.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 43
![Page 44: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/44.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
16) AIM: Write a JAVASCRIPT program to check given number is prime or not
PROGRAM:
<html><head><title>Prime Number </title><script type="text/javascript">var n;
function verify(){
if(n<0){
alert("Please enter positive number only");clear();exit();
}
}function prime(){
n = parseInt(document.getElementById('num1').value);verify();var count=0;for(i=2; i<n; i++){
if(n%i==0)count++;
}if(count==0)
alert("Given number is prime");else
alert("Given number is not prime");}
function clear()
Page 44
![Page 45: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/45.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
{document.getElementById('num1').value="";document.getElementById('res').value="";
}</script></head><body onload="clear()">
<form method="post">Number : <input type='text' id='num1' size='5'/> <br><input type='button' onclick='prime()' value='Check
Prime?' />
</form></body>
</html>
Page 45
![Page 46: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/46.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 46
![Page 47: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/47.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
17) AIM: Write a Servlet program to access details from a form PROGRAM:
studentform.html
<html><head><title>student form</title></head><body><center><form method="get" action="/staticform/student">enter student name: <input type=text name=sname><br><br>enter student age: <input type=text name=sage><br><br><input type="submit" name=send value="send"></form></center></body>
StudentEx.java
import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class StudentEx extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{res.setContentType("text/html");PrintWriter k = res.getWriter();String name = req.getParameter("sname");String age = req.getParameter("sage");k.println("<body bgcolor = cyan>");k.println("Hello: "+ name );k.println("your age:"+age);k.println("</body>");
Page 47
![Page 48: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/48.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
}
}
web.xml
<web-app><servlet><servlet-name>first</servlet-name><servlet-class>StudentEx</servlet-class></servlet><servlet-mapping><servlet-name>first</servlet-name><url-pattern>/student</url-pattern></servlet-mapping></web-app>
Page 48
![Page 49: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/49.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
OUTPUT:
Page 49
![Page 50: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/50.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 50
![Page 51: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/51.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
18)AIM: JDBC Standalone application to interact with database and store the employee details. PROGRAM:import java.sql.*;import java.io.*;
public class jdbc_1 {public static void main(String s[]) throws Exception{
/* Type 1 driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connecttion con=DriverManager.getConnection("jdbc:odbc:mydsn","scott","tiger");
*/
Class.forName("com.mysql.jdbc.Driver");Connection con=
DriverManager.getConnection("jdbc:mysql://localhost:3306/kiran","root","password");
String query="insert into employee values(?,?,?)";
// Taking input from console
DataInputStream dis=new DataInputStream(System.in);System.out.println("Enter Employee Name");String ename=dis.readLine();System.out.println("Enter Employee Number");String eno=dis.readLine();System.out.println("Enter Employee salary");int sal=Integer.parseInt(dis.readLine());
// Getting a Statement
PreparedStatement ps=con.prepareStatement(query);ps.setString(1,ename);ps.setString(2,eno);ps.setInt(3,sal);
Page 51
![Page 52: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/52.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
//Execute Query
int i=ps.executeUpdate();System.out.println("Query Executed Successfully into Employee
Table... no of records inserted are "+i);con.close();
}}
Data Base Script
Drop table Employee;
create table employee(ename varchar(20), eno varchar(20),sal varchar(10));
OUTPUT:
19)AIM:- The Web Application takes the user details from the user, interact with the database and checks with the database user details. If user details exists login to site else display login page again.
Page 52
![Page 53: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/53.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
PROGRAM:<html><body><center><h1>MY Company</h1><br><br><br>
<form name="form1" method="post" action="login"><table><tr>
<td><strong>User Name</strong></td><td><input type="text" name="uname"></td>
</tr><tr>
<td><strong>Password</strong></td><td><input type="Password" name="pass"></td>
</tr><tr>
<td> </td><td> </td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="Submit" value="Login"></td><td align="center"><input type="reset" name="Submit2" value="Reset"></tr></table>
</form></center></body></html>
import java.sql.*;
public class DBClass {public boolean validate(String uname,String pass){
try{/* Type 1 driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Page 53
![Page 54: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/54.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Connecttion con=DriverManager.getConnection("jdbc:odbc:mydsn","scott","tiger");
*/Class.forName("com.mysql.jdbc.Driver");Connection con=
DriverManager.getConnection("jdbc:mysql://localhost:3306/kiran","root","password");
Statement st= con.createStatement();ResultSet rs=st.executeQuery("select * from userdetails
where uname=\'" +uname+ "\'and pass=\'" +pass+ "\' ");return rs.next();
} catch(Exception e){e.printStackTrace();
}return false;
}}
import java.io.*;import javax.servlet.*;import javax.servlet.http.*;
public class LoginServlet extends HttpServlet {
DBClass ud;
public void init(){ud=new DBClass();}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
response.setContentType("text/html");PrintWriter out=response.getWriter();
String uname=request.getParameter("uname");String pass=request.getParameter("pass");ud=new DBClass();if(ud.validate(uname,pass)){
out.println("<h3>Welcome, "+uname+"<h3><br/>");
Page 54
![Page 55: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/55.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
out.println(" You have logged into the Site");
}else{
out.println("<h2>Your Details not found please login with valid details...</h2>");
out.println("</body></html>");}
}
}
Web.xml:-
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'><web-app> <servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>LoginServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>LoginServlet</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping> <welcome-file-list>
<welcome-file>Login.html</welcome-file> </welcome-file-list></web-app>
Page 55
![Page 56: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/56.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 56
![Page 57: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/57.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
20)AIM: JSP Pages to take input from the User redirect to Another JSP to Print name and Date
PROGRAM:
<%@page import="java.util.*"%><html><head><title>Welcome</title></head><body><%=new Date().toString()%><hr><h2>Welcome</h2>
<form action="show.jsp">User Name
<input type=text name="name"><br><br>City<input type=text name=city><br><br><input type="submit" name= "submit "value="submit"><input type="reset" name="Submit2" value="Reset">
</form></center></body>
Show.jsp
<%@page import="java.util.*"%><html><head><title>Welcome</title></head>
Page 57
![Page 58: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/58.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
<body><%=new Date().toString()%><hr>Hello<b><%=request.getParameter("name")%></b><br><br>Your City is <b><%=request.getParameter("city")%></b><br><br><a href="user.jsp">back</a></form></center></body>
Page 58
![Page 59: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/59.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 59
![Page 60: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/60.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 60
![Page 61: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/61.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
21)AIM:Web Application take Student detail from the User and Displays the Class . if student marks are >=60 then First Class if >=50 second class if less then 50% then fail.
PROGRAM:
Student Form
<html><head><title>Student Form</title></head><body><center><h2>Enter Student Details</h2><form method="post" action="student">
Student Name: <input type=text name=sname><br><br>
Student Age: <input type=text name=sage><br><br>
Sub1 marks <input type=text name=s1><br><br>
Sub2 marks<input type=text name=s2><br><br>Sub3 marks
<input type=text name=s3><br><br>
<input type="submit" name= "submit "value="submit"><input type="reset" name="Submit2" value="Reset">
</form></center></body>
StudentEx.java
import java.io.*;import javax.servlet.*;import javax.servlet.http.*;
Page 61
![Page 62: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/62.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
public class StudentEx extends HttpServlet{
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{res.setContentType("text/html");PrintWriter out = res.getWriter();String name = req.getParameter("sname");String age = req.getParameter("sage");int percent=0;int s1 = Integer.parseInt(req.getParameter("s1"));int s2 = Integer.parseInt(req.getParameter("s2"));int s3 = Integer.parseInt(req.getParameter("s3"));
int total=s1+s2+s3;percent=(total*100)/300;String msg=" ";if(percent>=100)msg="Enter Valid marks";else if(percent>=60)msg="Good Work You Got First Class";else if(percent>=50)msg=" You Got second Class";elsemsg="Oh You Failed... Work Hard Next time..";
out.println("<html>");out.println("<body bgcolor = cyan>");out.println("<h1>Hello: "+ name+"</h1>" );out.println("<h2>"+msg+"<h2>");out.println("</body>");out.println("</html>");
}
}
Web.xml
<web-app> <servlet>
Page 62
![Page 63: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/63.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
<servlet-name>s1</servlet-name> <servlet-class>StudentEx</servlet-class> </servlet> <servlet-mapping> <servlet-name>s1</servlet-name> <url-pattern>/student</url-pattern> </servlet-mapping> <welcome-file-list>
<welcome-file>studentform.html</welcome-file> </welcome-file-list> </web-app>
Page 63
![Page 64: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/64.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 64
![Page 65: Aps and Jwt Lab Manual](https://reader035.vdocuments.us/reader035/viewer/2022062223/552f165d4a7959d5588b4b29/html5/thumbnails/65.jpg)
ADVANCED PROBLEM SOLVING AND WEB TECHNOLOGIES LAB
Page 65