Computer Science, asked by devupallibabuji57, 9 months ago


3) Write a program in Java to calculate the diagonal of a cuboid taking length, breadth and
height as input. (diagonal=√1+b +h)​

Answers

Answered by hazellighte888
18

Answer:

/**

@Author:CandidJava

@Description: find Diagonal of the cuboid using Diacu Class

*/

import java.lang.Math;

class Diacu {

int breath, height, length;

double Dia;

Diacu(int b, int h, int l)// creating constructor

{

breath = b;

height = h;

length = l;

}

void bodyDiagonalOfCuboid()// creating method for calculate Diagonal of the

// cuboid

{

Dia = Math.sqrt(breath ^ 2 + height ^ 2 + length ^ 2);// calculate

// Diagonal

// using Math

System.out.println(Dia);// print Diagonal

}

public static void main(String args[]) {

Diacu s1 = new Diacu(55, 6, 7);// Create the object for Diacu

s1.bodyDiagonalOfCuboid();// CALL THE METHOD

}

}

Explanation:

Hope this helps

Similar questions