Pin It

How to calculate Volume and Surface Area of Cuboid in Java ?

Program to calculate Volume and Surface Area of Cuboid in Java ?

package com.hubberspot.mensuration.example;

import java.util.Scanner;

public class Cuboid {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    double length = 0;
    double breadth = 0;
    double height = 0;

    double volume = 0;
    double surfaceArea = 0;

    System.out.print("Enter the length of Cuboid : "); 
    length = input.nextDouble();

    System.out.print("Enter the breadth of Cuboid : "); 
    breadth = input.nextDouble();

    System.out.print("Enter the height of Cuboid : "); 
    height = input.nextDouble();

    volume = (length * breadth * height);
    surfaceArea = 2 * (length * breadth + breadth * height + height * length);
  
    System.out.println("");
    System.out.println("The Volume of Cuboid is : " + volume);
    System.out.println("The Surface Area of Cuboid is : " + surfaceArea);

 }
}

Output of the program :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot