import java.util.*;
import java.io.*;
class Big
{
public static void main(String[] args) throws IOException
{
int n,big,ch;
int num[]=new int[10];
DataInputStream in=new DataInputStream(System.in);
for(;;)
{
System.out.println("1.Biggest of Two");
System.out.println("2.Biggest of Three");
System.out.println("3.Biggest of N");
System.out.println("4.Exit");
System.out.println("Enter your choice:");
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1: System.out.println("Entrer 2 nos:");
int a=Integer.parseInt(in.readLine());
int b=Integer.parseInt(in.readLine());
big=biggest(a,b);
System.out.println("Big="+big);
break;
case 2: System.out.println("Enter 3 nos:");
a=Integer.parseInt(in.readLine());
b=Integer.parseInt(in.readLine());
int c=Integer.parseInt(in.readLine());
big=biggest(a,b,c);
System.out.println("Big="+big);
break;
case 3: System.out.println("Enter the limit");
n=Integer.parseInt(in.readLine());
System.out.println("Enter the elements:");
for(int i=0;i<n;i++)
num[i]=Integer.parseInt(in.readLine());
System.out.println("The elements are:");
for(int i=0;i<n;i++)
System.out.println(num[i]);
big=biggest(num,n);
System.out.println("Big="+big);
break;
default:System.exit(0);
}
}
}
static int biggest(int a, int b) // for two nos.
{
if (a>b)
{
return(a);
}
return(b);
}
static 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);
}
static 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;
}
}
import java.io.*;
class Big
{
public static void main(String[] args) throws IOException
{
int n,big,ch;
int num[]=new int[10];
DataInputStream in=new DataInputStream(System.in);
for(;;)
{
System.out.println("1.Biggest of Two");
System.out.println("2.Biggest of Three");
System.out.println("3.Biggest of N");
System.out.println("4.Exit");
System.out.println("Enter your choice:");
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1: System.out.println("Entrer 2 nos:");
int a=Integer.parseInt(in.readLine());
int b=Integer.parseInt(in.readLine());
big=biggest(a,b);
System.out.println("Big="+big);
break;
case 2: System.out.println("Enter 3 nos:");
a=Integer.parseInt(in.readLine());
b=Integer.parseInt(in.readLine());
int c=Integer.parseInt(in.readLine());
big=biggest(a,b,c);
System.out.println("Big="+big);
break;
case 3: System.out.println("Enter the limit");
n=Integer.parseInt(in.readLine());
System.out.println("Enter the elements:");
for(int i=0;i<n;i++)
num[i]=Integer.parseInt(in.readLine());
System.out.println("The elements are:");
for(int i=0;i<n;i++)
System.out.println(num[i]);
big=biggest(num,n);
System.out.println("Big="+big);
break;
default:System.exit(0);
}
}
}
static int biggest(int a, int b) // for two nos.
{
if (a>b)
{
return(a);
}
return(b);
}
static 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);
}
static 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;
}
}
No comments :
Post a Comment