Monday 23 March 2020

COMPUTING AREA AND VOLUME USING JAVA LANGUAGE

Q-15- Write a java program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas:
           area = radius * radius * π
           volume = area * length

INPUT :
 import java.util.Scanner;
public class NCM {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
double radius;
double length;
System.out.println("Enter The Radius And Length Of A Cylinder:");
radius=sc.nextDouble();
length=sc.nextDouble();
double area=3.141*radius*radius;
double volume=area*length;
System.out.println("The Area Is "+area);
System.out.println("The Volume Is "+volume);
}

}

OUTPUT :
 Enter The Radius And Length Of A Cylinder:
5.5
12
The Area Is 95.01525000000001
The Volume Is 1140.183

No comments:

Post a Comment