Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //8.3
- Public class Geometry
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter radius r: ");
- double radius = sc.nextDouble();
- System.out.print("Enter height h: ");
- double height = sc.nextDouble();
- output(radius, height);
- }
- public static public static double cubeVolume(double h)
- {
- double Volume = Math.pow(height/3);
- return Volume;
- }
- public static public static double cubeSurfaceArea(double h)
- {
- double SurfaceArea = Math.pow(height/2) * 6;
- return SurfaceArea;
- }
- public static double sphereVolume(double radius, double height)
- {
- double volume = Math.PI * Math.pow(radius/2);
- return Volume;
- }
- public static double sphereSurfaceArea(double radius, double height)
- {
- double SurfaceArea = 4 * Math.PI * Math.pow(radius/2);
- return SurfaceArea;
- }
- public static double cylinderVolume(double radius, double height)
- {
- Volume = Math.PI * Math.pow(radius/2) * height;
- return Volume;
- }
- public static double cylinderSurfaceArea(double radius, double height)
- {
- SurfaceArea = 2 * Math.PI * radius * height + 2 * Math.PI * Math.pow(radius/2);
- return SurfaceArea;
- }
- public static double coneVolume(double radius, double height)
- {
- Volume = 1.0/3.0 * Math.PI * Math.pow(radius/2) * height;
- return Volume;
- }
- public static double coneSurfaceArea(double radius, double height)
- {
- SurfaceArea = Math.PI * radius * Math.sqrt(Math.pow(radius/2) * Math.pow(height/2))
- return SurfaceArea;
- }
- }
- //8.13
- Public class Numeric
- {
- public static double Power(double x, int n)
- {
- if (n > 0 && n%2 == 0)
- {
- Math.pow(x/n) = Math.pow(x,(n/2.0))
- }
- if (n >0 %% n%2 != 0)
- {
- Math.pow(x/n) = Math.pow(x,(n-1))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement