Computer Science, asked by Atlas99, 4 hours ago

JAVA PROGRAMMING

Write a program to input length, bredth and height of a cuboid, calculate and display its area.​

Answers

Answered by anindyaadhikari13
6

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Java.

import java.util.Scanner;

public class CuboidVolume{

   public static void main(){

       Scanner sc=new Scanner(System.in);

       double l,b,h;

       System.out.print("Enter length of cuboid: ");

       l=sc.nextDouble();

       System.out.print("Enter breadth of rectangle: ");

       b=sc.nextDouble();

       System.out.print("Enter height of the rectangle: ");

       h=sc.nextDouble();

       sc.close();

       System.out.print("The volumne of the cuboid will be: "+l*b*h+" cubic units.");

   }

}

\textsf{\large{\underline{Algorithm}:}}

  1. Accept the length, breadth and height from the user.
  2. As we know that Volume = LBH, substitute the value into the formula and get the volume.
  3. Volume is calculated. So display it.

\textsf{\large{\underline{Sample I/O}:}}

Enter length of cuboid: 10

Enter breadth of rectangle: 8

Enter height of the rectangle: 6

The volumne of the cuboid will be: 480.0 cubic units.

Attachments:

anindyaadhikari13: Thanks for the brainliest :)
Answered by TheUntrustworthy
4

Prógram in Java to input length, bredth and height of a cuboid, calculate and display its area.

Note:

Area of Top & Bottom Surfaces = lw + lw = 2lw.

Area of Front & Back Surfaces = lh + lh = 2lh.

import java.util.*;

class Area

{

public static void main()

{

Scanner sc=new Scanner(System .in);

double l,w,h;

System.out.print("Enter length of cuboid: ");

l=sc.nextDouble();

System.out.print("Enter wídth of rectangle: ");

w=sc.nextDouble();

System.out.print("Enter height of the rectangle: ");

h=sc.nextDouble();

System.out.print("The area of the cuboid will be: "+2*l*w*h+2*l*h+"³");

}

}

Similar questions