Answer to Question #253618 in Java | JSP | JSF for Sara

Question #253618

6-Write a program to calculate the area of a circle. Use the formula Pi * r * r to work the program. Remember Pi is a constant and r is a variable entered by the user at runtime (once the program is running). Format the answer to 2 decimal places.


1
Expert's answer
2021-10-20T00:06:49-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Radius: ");
        double radius = in.nextDouble();
        System.out.printf("Area: %.2f", Math.PI * radius * radius);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS