//Filename : LinSearch.html
<!--04_Html program to read search key-->
<HTML>
<HEAD>
<TITLE>Linear Search</TITLE>
</HEAD>
<BODY>
<H1>Program to search name using Linear Search.</H1>
<FORM ACTION="LinSearch.jsp" METHOD="POST">
Please enter your the search key:
<BR>
<input NAME="text1" type="text">
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</BODY>
<HTML>
//Filename:LinSearch.jsp
<!--04. Program to search a given name using linear search.-->
<html>
<body>
<%
final String str[]={"Pineapple" , "Orange" , "Apple", "Grapes",
"Banana"};
String temp;
int flag=0,j;
%>
<h2>The list of names:</h2>
<%
for(j=0; j<str.length;j++)
{
out.println(str[j]+"<br>");
}
%>
<br>
<%
String key=request.getParameter("text1");
for(j=0; j<str.length;j++)
{
if(str[j].compareTo(key)==0)
{
flag=1;
break;
}
}
if(flag==1)
out.println("Search Key Found at location "+(j+1));
else
out.println("Search Key Not Found!");
%>
<body>
</html>
<!--04_Html program to read search key-->
<HTML>
<HEAD>
<TITLE>Linear Search</TITLE>
</HEAD>
<BODY>
<H1>Program to search name using Linear Search.</H1>
<FORM ACTION="LinSearch.jsp" METHOD="POST">
Please enter your the search key:
<BR>
<input NAME="text1" type="text">
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</BODY>
<HTML>
//Filename:LinSearch.jsp
<!--04. Program to search a given name using linear search.-->
<html>
<body>
<%
final String str[]={"Pineapple" , "Orange" , "Apple", "Grapes",
"Banana"};
String temp;
int flag=0,j;
%>
<h2>The list of names:</h2>
<%
for(j=0; j<str.length;j++)
{
out.println(str[j]+"<br>");
}
%>
<br>
<%
String key=request.getParameter("text1");
for(j=0; j<str.length;j++)
{
if(str[j].compareTo(key)==0)
{
flag=1;
break;
}
}
if(flag==1)
out.println("Search Key Found at location "+(j+1));
else
out.println("Search Key Not Found!");
%>
<body>
</html>
No comments :
Post a Comment