public static void main (String [] ars) {
int pi = 3.14;
int radius = 5;
int circumference = = 2*pi*r;
System.out.println("The circumference is: " + circumference)
}
can anyone anwer this please?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
gegjwkaa
3 January 2022, 17:26
how do i write that code?
0
Guadalupe Gagnon
3 January 2022, 17:04useful
Hi. What is your question? Is it why the code doesn't compile?
- First, on line number 2, the value 3.14 is not an int because ints can not store floating point (decimal) values. The compiler will not accept this so you either need to change the type to something that can store a floating point number or change the value to be a non-floating point value.
- Next, on the 4th line there should only be one equals sign, having two equals signs is incorrect.
- Next, on that same line, the variable 'r' is used however that does not exist in this code. Maybe you meant to use 'radius' instead, which does exist.
I hope this answers your concerns, but if it does not then please specify what it is that you are asking.
+1