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
Square Root calculation for given numbers using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
487
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssvsqrt.rar
// Sqrt program
class
ssvsqrt
{
public
static
void
main(String args[])
{
System.out.print(
"\n\n\n | "
);
for
(
double
j=
0.0
;j<=
0.9
;j+=
0.1
)
if
((j >
0.7
) && (j <
0.9
)) { j =
0.8
;System.out.print(j+
" "
); }
else
System.out.print(String.valueOf(j).substring(
0
,
3
)+
" "
);
System.out.print(
"\n -----|---------------------------------------------------------------------"
);
System.out.print(
"\n \n | \n "
);
for
(
double
i=
0.0
;i<=
9.0
;i++)
{ System.out.print(i +
" | "
);
for
(
double
j=
0.0
;j<=
0.9
;j+=
0.1
)
{
if
( (Math.sqrt(i+j) ==
0.0
) || (Math.sqrt(i+j) ==
1.0
)|| (Math.sqrt(i+j) ==
2.0
)|| (Math.sqrt(i+j) ==
3.0
))
System.out.print(Math.sqrt(i+j)+
" "
);
else
System.out.print(String.valueOf( Math.sqrt(i+j)).substring(
0
,
4
) +
" "
);
}
System.out.print(
"\n "
);
}
}
}
Java