P
P
PRAIT2019-06-11 18:27:03
Java
PRAIT, 2019-06-11 18:27:03

Is the program correctly written that calculates and displays the circumference of a circle if its radius is read from the keyboard?

And again the question guys, please answer.
I need to write a SUBJ program.
Is the program written correctly?

package pack;

import java.util.Scanner;

public class three {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      double a;
      System.out.println("number");
      a = sc.nextDouble();
      double c = Math.PI * a;
      System.out.println("" + c);
    }
  }
}

Instead of pi 3.14 we used Math.PI
And this is the option
package pack;

import java.util.Scanner;

public classthree {

  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      double a;
      System.out.println("number");
      a = sc.nextDouble();
      double c = 3.14 * a;
      System.out.println("" + c);
    }
  }
}

Thanks to all!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2019-06-11
@BorisKorobkov

Not right.
The circumference of a circle is not πr. Open your math textbook

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question