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
Square Root calculation for given numbers using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
514
0
1
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
Up Next
Square Root calculation for given numbers using Java