Convert it from python to java. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Convert it from python to java.

This program outputs the value of Pi till desired digits. Being a java programmer, i have zero knowledge of python language. Can u help my converting this bit of program to java. ___________________________________________ n=int(input('')) p=a=10**n i=9*n while i: d=2*i+1 p=(p*i%a+(p*i//a+3*i)%d*a+i)//d i-=1 print ('3.%d'%p) ___________________________________________

1st Jan 2020, 10:56 AM
Priya
Priya - avatar
1 Answer
+ 3
Priya I think you know how to take user input in Java so 1st line is done. For ** which is an exponentiation operator, you can use Math.pow() in Java so the 2nd line is also done. The rest is a while loop which is pretty straightforward and the // operator just floors the floating value so you can use Math.floor() in Java for that. Hope you have got some understanding now, kindly make an attempt to write an equivalent code in Java and if you are stuck then someone will surely help you. Even I'm not a Python programmer, but knowing the basics always helps👍
1st Jan 2020, 11:12 AM
Avinesh
Avinesh - avatar