Publicidad
Write a program to compute the volume V of a cylinder of radius r and.docx
Write a program to compute the volume V of a cylinder of radius r and.docx
Próximo SlideShare
Java programming lab manualJava programming lab manual
Cargando en ... 3
1 de 2
Publicidad

Más contenido relacionado

Similar a Write a program to compute the volume V of a cylinder of radius r and.docx(20)

Más de lez31palka(20)

Publicidad

Write a program to compute the volume V of a cylinder of radius r and.docx

  1. Write a program to compute the volume V of a cylinder of radius r and height h. (Recall that V = r2h.) do steps 2 through 5 of the engineering problem solving methodology for the problem above and submit a screenshot of the program and output as well as test the program with variety of data Solution Cylinder.java import java.text.DecimalFormat; import java.util.Scanner; public class Cylinder { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#.00"); System.out.println("Enter Cylinder Radius : "); double radius = scan.nextDouble(); System.out.println("Enter Cylinder Height : "); double height = scan.nextDouble(); double volumn = Math.PI * radius * radius * height; System.out.println("The volumn of cylinder is : "+df.format(volumn)); } } Output:
  2. Enter Cylinder Radius : 3 Enter Cylinder Height : 4 The volumn of cylinder is : 113.10 Enter Cylinder Radius : 8.5 Enter Cylinder Height : 9.5 The volumn of cylinder is : 2156.31
Publicidad