<!--01. JSP Program to find biggest of 2,3 and N numbers using method overloading.-->
<HTML>
<HEAD>
<TITLE>Biggest Number</TITLE>
<%@ page import="java.io.*,java.util.*,java.lang.*" %>
</HEAD>
<BODY>
<H1>JSP Program to find biggest of 2,3 and N numbers.</H1>
<BR>
<%!int str[]=new int[20];%>
<%int i;int a;int big=0;
int num[]={12,45,78,5,744,54,6};
int len=num.length;
if(len<=1)
out.println("Enter atleast 2 numbers to compare.");%>
<BR>
<font color="Red">Given Numbers are:</font>
<%
for(i=0;i<len;i++)
out.println(num[i]);
%>
<BR>
<%
out.println("Biggest Number is:");
if(len==2)
big=biggest(num[0],num[1]);
else if(len==3)
big =biggest(num[0],num[1],num[2]);
else
big=biggest(num,len);
out.println(big);
%>
<%!
int biggest(int a, int b) // for two nos.
{
if (a>b)
{
return(a);
}
return(b);
}
int biggest(int a , int b, int c) //for three nos.
{
int big1;
if (a>b && a>c)
{
big1 = a;
}
else
{
if (b>c)
{
big1 = b;
}
else
{
big1 = c;
}
}
return(big1);
}
int biggest(int num[], int n) //for n numbers
{
int big1;
big1=num[0];
for(int i=0;i<n;i++)
{
if(num[i]>big1)
big1=num[i];
}
return big1;
}
%>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Biggest Number</TITLE>
<%@ page import="java.io.*,java.util.*,java.lang.*" %>
</HEAD>
<BODY>
<H1>JSP Program to find biggest of 2,3 and N numbers.</H1>
<BR>
<%!int str[]=new int[20];%>
<%int i;int a;int big=0;
int num[]={12,45,78,5,744,54,6};
int len=num.length;
if(len<=1)
out.println("Enter atleast 2 numbers to compare.");%>
<BR>
<font color="Red">Given Numbers are:</font>
<%
for(i=0;i<len;i++)
out.println(num[i]);
%>
<BR>
<%
out.println("Biggest Number is:");
if(len==2)
big=biggest(num[0],num[1]);
else if(len==3)
big =biggest(num[0],num[1],num[2]);
else
big=biggest(num,len);
out.println(big);
%>
<%!
int biggest(int a, int b) // for two nos.
{
if (a>b)
{
return(a);
}
return(b);
}
int biggest(int a , int b, int c) //for three nos.
{
int big1;
if (a>b && a>c)
{
big1 = a;
}
else
{
if (b>c)
{
big1 = b;
}
else
{
big1 = c;
}
}
return(big1);
}
int biggest(int num[], int n) //for n numbers
{
int big1;
big1=num[0];
for(int i=0;i<n;i++)
{
if(num[i]>big1)
big1=num[i];
}
return big1;
}
%>
</BODY>
</HTML>