Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Sphere here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.util.Scanner;
- public class Sphere
- {
- public static void main(String [] args){
- //Initialize Variable
- double radius;
- //Scanner Object
- Scanner keyboard = new Scanner(System.in);
- //Heading
- System.out.println("Pedro's Sphere Surface Area And Volume Calculator");
- System.out.println(" =================================================");
- //Ask user for radius
- System.out.print(" Enter the radius of the sphere: ");
- radius = keyboard.nextDouble();
- //Display Volume
- System.out.print(" The volume of the sphere is: ");
- System.out.println(4.0/3 * Math.PI * Math.pow(radius, 3));
- //Spacer
- System.out.println("");
- //Display Surface Area
- System.out.print(" The surface area of the sphere is: ");
- System.out.println(4.0 * Math.PI * Math.pow(radius, 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement