In: Computer Science
Write a program to calculate the area and circumference of a cuboid.
Use printf to display 2 digits after decimal point in all the results
Program should be in java language.
Code
import java.util.*;
import java.lang.*;
import java.io.*;
class T
{
public static void main (String[] args) throws
java.lang.Exception
{
Scanner in= new
Scanner(System.in);
float l,b,h;
System.out.println( "Enter values
of length");
l=in.nextFloat(); //input
length
System.out.println( "Enter values
of breadth ");
b=in.nextFloat(); //input
bradth
System.out.println( "Enter values
of height");
h=in.nextFloat(); //input
height
float A,C;
A=2*(l*b +b*h + h*l); //calculate
surface area
C=4*(l+b+h); //calculate
circumference
System.out.printf("Area of cuboid
is %.2f \n", A);
System.out.printf("Circumference of
cuboid is %.2f \n", C);
}
}
Terminal work