Write a program in java to input 3 numbers and find the second largest number.
Answers
//to find the second largest no
import java.io.*;
class seclar
{
public static void main (String args[]) throws IOException
{
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
int a,b,c,d=0,min=0,max=0,e=0;
System.out.prinln("enter 3 no");
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=Integer.parseInt(br.readLine());
// find sum of 3 no
d=a+b+c;
max=a;// let a be the largest
min=a; let a be the smallest
if(b>max)
max= b;
else if (c>max)
max=c;
else
max=a;// finding the largest of
3 numbers
if(b<min)
min= b;
else if(c<min)
min = c;
else
min=a;//finding the smallest of
3 no
e= d-(max+min);// finding the
second largest no
}
}
Hope it helps !!!
mark me as the brainliest⭐⭐⭐⭐⭐
Answer:import java.io.*;
class seclar
{
public static void main (String args[]) throws IOException
{
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
int a,b,c,d=0,min=0,max=0,e=0;
System.out.prinln("enter 3 no");
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
c=Integer.parseInt(br.readLine());
// find sum of 3 no
d=a+b+c;
max=a;// let a be the largest
min=a; let a be the smallest
if(b>max)
max= b;
else if (c>max)
max=c;
else
max=a;// finding the largest of
3 numbers
if(b<min)
min= b;
else if(c<min)
min = c;
else
min=a;//finding the smallest of
3 no
e= d-(max+min);// finding the
second largest no
}
}
Read more on Brainly.in - https://brainly.in/question/9771808#readmore