Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Calculate The Smallest Number In The Given Array Using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
726
0
0
ssva22.rar
/* LOWEST NUMBER */
import
java.io.*;
import
java.text.*;
class
ssva22
{
public
static
void
main(String arg[])
throws
IOException
{
double
a[]=
new
double
[
20
],temp=
0
;
int
i,j,n;
BufferedReader obj=
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.println(
"\n LOWEST 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
(i=
0
;i<n;i++)
{
a[i]=Double.parseDouble(obj.readLine());
}
for
(i=
0
;i<n-
1
;i++)
{
for
(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 LOWEST NUMBER IS : "
+nf.format(a[i]));
System.out.println(
"\n"
);
}
}
Java
Up Next
Calculate The Smallest Number In The Given Array Using Java