Answer:
import java.util.Scanner;
public class num5 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter base heigth of the cylinder");
double heigth = in.nextDouble();
System.out.println("Enter radius of the cylinder");
double radius = in.nextDouble();
// vol = pi*r2*h area = 2π r h + 2π r².
double volCylinder = Math.PI*(radius*radius)*heigth;
double surfaceAreaCylinder = (2*Math.PI*radius*heigth)+
(2*Math.PI*(radius*radius));
// Outputs
System.out.printf("The Vol of the cylinder %.2f \\",volCylinder);
System.out.printf("The surface Area %.2f \\", surfaceAreaCylinder);
}
}
Step-by-step explanation:
The program is written in Java.
Prompt user for height and radius of the cylinder. Store in the repective variables
Calculate Volume of the cylinder
Calculate Surface Area
Using Java's printf function to output result to 2 decimal places