Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class PartB {
- public static void main(String[] args) {
- double radius;
- Scanner userInput = new Scanner(System.in);
- DecimalFormat df = new DecimalFormat("#.000");
- System.out.println("Input the radius: ");
- radius = userInput.nextDouble();
- System.out.println("The Circumference of the Circle is: "
- + df.format(calculateCircumference(radius)));
- System.out.println("The Diameter of the Circle is: "
- + df.format(calculateDiameter(radius)));
- System.out.println("The Area of the Circle is: "
- + df.format(calculateCircleArea(radius)));
- System.out.println("The Volume of the Sphere is: "
- + df.format(calculateVolumeSphere(radius)));
- }
- public static double calculateCircumference(double radius) {
- double result;
- result = 2 * Math.PI * radius;
- return result;
- }
- public static double calculateDiameter(double radius) {
- double result;
- result = radius * 2;
- return result;
- }
- public static double calculateCircleArea(double radius) {
- double result;
- result = Math.PI * Math.pow(radius, 2);
- return result;
- }
- public static double calculateVolumeSphere(double radius) {
- double result;
- result = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement