What's new

Java java java

jazzL11

Addict
Joined
Aug 20, 2016
Posts
96
Reaction
17
Points
103
Age
26
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 👆
 
Last edited by a moderator:
[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]
 

Similar threads

Back
Top