Computer Science, asked by arishowaisp87ktn, 1 year ago

pls help it's a programming question

Attachments:

Answers

Answered by nitish8089
0
check \: out \: the \: code
import java.util.Scanner;
public class Program
{
public static void volume(int r, float h){
float volume=(1.0f/3)*(3.14f*r*r*h);
System.out.println("radius of cone: "+r);
System.out.println("height of cone: "+h);
System.out.println("Volume of cone: "+volume);
}
public static void volume(float r, float h){
float volume=(3.14f*r*r*h);
System.out.println("radius of cylinder: "+r);
System.out.println("height of cone: "+h);
System.out.println("Volume of cylinder: "+volume);
}
public static void volume(float r){
float volume=(4.0f/3)*(3.14f*r*r*r);
System.out.println("radius of sphere: "+r);
System.out.println("Volume of sphere: "+volume);
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
float b=sc.nextFloat();
float c=sc.nextFloat();
Program.volume(a,b);
Program.volume(b,c);
Program.volume(a);
}
}
output ✅
Attachments:
Similar questions