+ 2
Why it is not taking input?
import java.util.Scanner; class program { public static void main(String[] args) { Scanner circle = new Scanner(System.in); System.out.println("Enter radius"); int r = circle.nextInt(); System.out.println("Enter pi"); int pi = circle.nextInt(); int a = pi*r*r; int c = 2*pi*r; System.out.println("Loding answer.....!"); System.out.println("The Area of tge circle is = " + (a)); System.out.println("The circumference of the circle is = " + (c)); } }
12 Antworten
+ 2
//You can copy paste link here also...
//that works. . but also you can have changes .. read comments,
import java.util.Scanner;
class program
{
public static void main(String[] args) {
Scanner circle = new Scanner(System.in);
System.out.println("Enter radius");
int r = circle.nextInt();
System.out.println("Enter pi");
double pi = circle.nextDouble();
/*to take double values , use nextDouble() like this
//but you can take pi value as Math.PI directly without taking user input try
pi=Math.PI;
*/
double a = pi*r*r;
double c = 2*pi*r;
System.out.println("Loding answer.....!");
System.out.println("The Area of tge circle is = " + a);
System.out.println("The circumference of the circle is = " + c);
}
}
+ 3
Mayukh Banerjee ,
when i use your code, the input window opens, so i used:
10
3.14
as input. after using submit scroll down, so you can find some error messages. so the input is taken.
there is a bunch of issues i found in the code. most of them are related to the data type of pi. if you input 3.14 as pi, your code is trying to assign it to an int varisble. but has to be double. check also the following lines for related issues.
the output has also 2 issues, just check for unnecessary braces around variable names.
+ 2
Now also not taking input it's only showing enter radius
+ 2
Mayukh Banerjee In sololearn, u can only give input once. u can't dynamically load input and output.
+ 2
@Mayukh Banerjee
on pop- up window here, enter values
ex:
5 3
and hit submit button, you can see output...
edit:
Others logic issues if you find,then you can find in @Lothar post.
already posted so adding here.
If your program needs multiple inputs ,then give all required inputs for code in pop up by space separated or in new line in required order at a time in pop-up box.. it's not an interactive.
This explains how solo learn input console works...
https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
+ 2
Ok thank you
+ 2
Thanks
+ 1
No I am not asked about pi i have asked about why it is not taking input
+ 1
Its should be
int a=pi*r*r;
Not the subscript notation, you are using .its invalid in java.
+ 1
Is it right now guys
+ 1
Check in my code bits
0
Where is your update code?
Don't change your original question. Add a new post or link with the changes.. otherwise it confuses to readers.
It works with that single change. But you have to tell "is you getting your expected output or not".
Generally PI value is fixed constant 3.14... you can get it by Math.PI exact value , no need to take from user. And if you want to store,then use a double type variable. If you need integer as result then use type cast back..