Computer Applications

The volume of a sphere is calculated by using formula:
v = (4/3)*(22/7)*r3

Write a program to calculate the radius of a sphere by taking its volume as an input.

Hint: radius = ∛(volume * (3/4) * (7/22))

Java

Java Math Lib Methods

50 Likes

Answer

import java.util.Scanner;

public class KboatSphere
{
    public static void main(String args[]) {
        
        Scanner in = new Scanner(System.in);
        
        System.out.print("Enter volume of sphere: ");
        double v = in.nextDouble();
        
        double r = Math.cbrt(v * (3 / 4.0) * (7 / 22.0));
        System.out.println("Radius of sphere = " + r);
    }
}

Variable Description Table

Program Explanation

Output

Answered By

20 Likes


Related Questions