๐Ÿ”’ Closed Java java java

Status
Not open for further replies.

jazzL11

Enthusiast
Guys alam nyo code nito for java?


Create a program that will print the volume of a cylindrical cone if you
input the height and the base of the cylinder. Use the formula: V = 1/3 *
B * H

Sample Input/Output

Enter the Base of the cone: 17
Enter the Height of the cone: 67
The Volume is 379.6666666666667
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
class VolumeOfCylinder
{

public static void main(String args[])
{

Scanner s= new Scanner(System.in);

System.out.println("Enter the base of the cone:");
double b=s.nextDouble();
System.out.println("Enter the height of the cone:");
double h=s.nextDouble();


double a=VolumeOfCylinder.Volume(b,h);

System.out.println("The volume is:" +a);
}

public static double Volume(double b,double h)
{

double a=((b*h)/3);


return a;
}

}
}


jazzL11 ๐Ÿ‘†
 
[CODE lang="java" title="Volume"]public class Main
{
public static void main(String[] args) {
volume(17,67);
}
static void volume(double b, double h){
System.out.printf("Volume: %.2f", (b*h)/3);
}
}[/CODE]
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 360
    Views
  • 4
    Participants
Last reply from:
jazzL11

Online now

Members online
997
Guests online
1,228
Total visitors
2,225

Forum statistics

Threads
2,277,039
Posts
28,973,868
Members
1,229,695
Latest member
Smile2742
Back
Top