Sunday, 5 November 2017

java program very important programs



 Write a program that reads in the radius
and length of a cylinder and computes the area and volume
Description:
using the following
formulas:
area = radius * radius * p
volume = area * length
Solution
 import java.util.*;
public class Message {
 public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
   float radius,area,lenght,pi=3.14f;
   System.out.println("Enter the radius");
   radius=in.nextFloat();
   System.out.println("Enter the lenght");
   lenght=in.nextFloat();
   area=pi*radius*radius;
   System.out.println("The area of clyinder = "+area);
   System.out.println("The volume of clyinder ="+(area*lenght));
 }
}

Output
                   

No comments:

Post a Comment