TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Calculate The Largest Number In The Given Array Using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
975
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssva21.rar
/* BIGGEST NUMBER */
import
java.io.*;
import
java.text.*;
class
ssva21
{
public
static
void
main(String arg[])
throws
IOException
{
double
a[]=
new
double
[
20
],temp=
0
;
int
n;
BufferedReader obj=
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.println(
"\n BIGGEST NUMBER"
);
System.out.println(
" --------------"
);
System.out.print(
"\nENTER HOW MANY NUMBER : "
);
n=Integer.parseInt(obj.readLine());
NumberFormat nf=NumberFormat.getInstance();
nf.setMaximumFractionDigits(
2
);
nf.setMinimumFractionDigits(
0
);
System.out.println(
"\nENTER THE NUMBERS\n"
);
for
(
int
i=
0
;i<n;i++)
{
a[i]=Double.parseDouble(obj.readLine());
}
for
(
int
i=
0
;i<n-
1
;i++)
{
for
(
int
j=i+
1
;j<n;j++)
{
if
(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println(
"\nTHE BIGGEST NUMBER IS : "
+nf.format(temp));
System.out.println(
"\n"
);
}
}
Java