Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java write a program that reads in the radius and length of a cylinder and

ID: 3835689 • Letter: U

Question

Using Java write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas:

1.  Bottom area = Radius * Radius * 3.14
2.  Cylinder Volume = Bottom Area * Length
3.  Cylinder area = (2 * Radius * 3.14 * Length) + (2 * Bottom area)


Your program should prompt the user to enter the radius and length of a cylinder. The program should output the length and radius of the cylinder along with the area and volume of the cylinder. Limit the output values to two decimal places

Explanation / Answer

import java.util.Scanner;

public class CylinderOp {

  

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

      

       System.out.print("Enter radius of cylinder: ");

       double radius = sc.nextDouble();

       System.out.print("Enter length of cylinder: ");

       double length = sc.nextDouble();

      

       double bottomArea = 3.14*radius*radius;

       double volume = bottomArea*length;

      

       double area = 2*3.14*radius*length + 2*bottomArea;

      

       System.out.println("Length of cylinder: "+String.format("%.2f", length));

       System.out.println("Radius of cylinder: "+String.format("%.2f", radius));

       System.out.println("Area of cylinder: "+String.format("%.2f", area));

       System.out.println("Volume of cylinder: "+String.format("%.2f", volume));

   }

}

/*

Sample run:

Enter radius of cylinder: 4.65

Enter length of cylinder: 8.7

Length of cylinder: 8.70

Radius of cylinder: 4.65

Area of cylinder: 389.85

Volume of cylinder: 590.68

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote