Find surface area of cuboid

Here given code implementation process.

/*
  C Program 
  Find surface area of cuboid
*/
#include <stdio.h>

//Calculate surface area of cuboid by length,width and height
void cuboid_surface_area(double length, double width, double height)
{
	printf("\nGiven Length : %lf, Width : %lf , Height : %lf", length, width, height);
	// Formula of cuboid surface area 
	// (2*length*width)+(2*length*height)+(2*width*height)
	// Calculate surface area of cuboid
	double result = (2 * length * width) + (2 * length * height) + (2 * width * height);
	//Display result
	printf("\nSurface area of cuboid : %lf\n", result);
}
int main()
{
	//Simple Case
	cuboid_surface_area(3.5, 5.5, 7.2);
	cuboid_surface_area(2, 3, 5);
	cuboid_surface_area(7, 5.4, 5);
	return 0;
}

Output

Given Length : 3.500000, Width : 5.500000 , Height : 7.200000
Surface area of cuboid : 168.100000

Given Length : 2.000000, Width : 3.000000 , Height : 5.000000
Surface area of cuboid : 62.000000

Given Length : 7.000000, Width : 5.400000 , Height : 5.000000
Surface area of cuboid : 199.600000
// Java Program
// Find surface area of cuboid
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	void cuboid_surface_area(double length, double width, double height)
	{
		System.out.print("\nGiven Length : " + length + ", Width : " + width + " , Height : " + height);
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		double result = (2 * length * width) + (2 * length * height) + (2 * width * height);
		//Display result
		System.out.print("\nSurface area of cuboid : " + result + " \n");
	}
	public static void main(String[] args)
	{
		Cuboid obj = new Cuboid();
		//Simple Case
		obj.cuboid_surface_area(3.5, 5.5, 7.2);
		obj.cuboid_surface_area(2, 3, 5);
		obj.cuboid_surface_area(7, 5.4, 5);
	}
}

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.10000000000002

Given Length : 2.0, Width : 3.0 , Height : 5.0
Surface area of cuboid : 62.0

Given Length : 7.0, Width : 5.4 , Height : 5.0
Surface area of cuboid : 199.60000000000002
// C++ Program
// Find surface area of cuboid
#include<iostream>
using namespace std;
class Cuboid
{
	public:
		//Calculate surface area of cuboid by length,width and height
		void cuboid_surface_area(double length, double width, double height)
		{
			cout << "\nGiven Length : " << length << ", Width : " << width << " , Height : " << height;
			// Formula of cuboid surface area 
			// (2*length*width)+(2*length*height)+(2*width*height)
			// Calculate surface area of cuboid
			double result = (2 * length * width) + (2 * length * height) + (2 * width * height);
			cout << "\nSurface area of cuboid : " << result << " \n";
		}
};
int main()
{
	Cuboid obj;
	//Simple Case
	obj.cuboid_surface_area(3.5, 5.5, 7.2);
	obj.cuboid_surface_area(2, 3, 5);
	obj.cuboid_surface_area(7, 5.4, 5);
	return 0;
}

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.1

Given Length : 2, Width : 3 , Height : 5
Surface area of cuboid : 62

Given Length : 7, Width : 5.4 , Height : 5
Surface area of cuboid : 199.6
// C# Program
// Find surface area of cuboid
using System;
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	void cuboid_surface_area(double length, double width, double height)
	{
		Console.Write("\nGiven Length : " + length + ", Width : " + width + " , Height : " + height);
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		double result = (2 * length * width) + (2 * length * height) + (2 * width * height);
		Console.Write("\nSurface area of cuboid : " + result + " \n");
	}
	public static void Main(String[] args)
	{
		Cuboid obj = new Cuboid();
		//Simple Case
		obj.cuboid_surface_area(3.5, 5.5, 7.2);
		obj.cuboid_surface_area(2, 3, 5);
		obj.cuboid_surface_area(7, 5.4, 5);
	}
}

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.1

Given Length : 2, Width : 3 , Height : 5
Surface area of cuboid : 62

Given Length : 7, Width : 5.4 , Height : 5
Surface area of cuboid : 199.6
<?php
// Php Program
// Find surface area of cuboid
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	function cuboid_surface_area($length, $width, $height)
	{
		echo "\nGiven Length : ". $length .", Width : ". $width ." , Height : ". $height;
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		$result = (2 * $length * $width) + (2 * $length * $height) + (2 * $width * $height);
		echo "\nSurface area of cuboid : ". $result ." \n";
	}
}

function main()
{
	$obj = new Cuboid();
	//Simple Case
	$obj->cuboid_surface_area(3.5, 5.5, 7.2);
	$obj->cuboid_surface_area(2, 3, 5);
	$obj->cuboid_surface_area(7, 5.4, 5);
}
main();

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.1

Given Length : 2, Width : 3 , Height : 5
Surface area of cuboid : 62

Given Length : 7, Width : 5.4 , Height : 5
Surface area of cuboid : 199.6
// Node Js Program
// Find surface area of cuboid
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	cuboid_surface_area(length, width, height)
	{
		process.stdout.write("\nGiven Length : " + length + ", Width : " + width + " , Height : " + height);
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		var result = (2 * length * width) + (2 * length * height) + (2 * width * height);
		process.stdout.write("\nSurface area of cuboid : " + result + " \n");
	}
}

function main()
{
	var obj = new Cuboid();
	//Simple Case
	obj.cuboid_surface_area(3.5, 5.5, 7.2);
	obj.cuboid_surface_area(2, 3, 5);
	obj.cuboid_surface_area(7, 5.4, 5);
}
main();

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.10000000000002

Given Length : 2, Width : 3 , Height : 5
Surface area of cuboid : 62

Given Length : 7, Width : 5.4 , Height : 5
Surface area of cuboid : 199.60000000000002
#  Python 3 Program
#  Find surface area of cuboid
class Cuboid :
	# Calculate surface area of cuboid by length,width and height
	def cuboid_surface_area(self, length, width, height) :
		print("\nGiven Length : ", length ,", Width : ", width ," , Height : ", height, end = "")
		#  Formula of cuboid surface area 
		#  (2*length*width)+(2*length*height)+(2*width*height)
		#  Calculate surface area of cuboid
		result = (2 * length * width) + (2 * length * height) + (2 * width * height)
		print("\nSurface area of cuboid : ", result ," \n", end = "")
	

def main() :
	obj = Cuboid()
	# Simple Case
	obj.cuboid_surface_area(3.5, 5.5, 7.2)
	obj.cuboid_surface_area(2, 3, 5)
	obj.cuboid_surface_area(7, 5.4, 5)

if __name__ == "__main__": main()

Output

Given Length :  3.5 , Width :  5.5  , Height :  7.2
Surface area of cuboid :  168.10000000000002

Given Length :  2 , Width :  3  , Height :  5
Surface area of cuboid :  62

Given Length :  7 , Width :  5.4  , Height :  5
Surface area of cuboid :  199.60000000000002
#  Ruby Program
#  Find surface area of cuboid
class Cuboid

	# Calculate surface area of cuboid by length,width and height
	def cuboid_surface_area(length, width, height)
	
		print("\nGiven Length : ", length ,", Width : ", width ," , Height : ", height)
		#  Formula of cuboid surface area 
		#  (2*length*width)+(2*length*height)+(2*width*height)
		#  Calculate surface area of cuboid
		result = (2 * length * width) + (2 * length * height) + (2 * width * height)
		# Display result
		print("\nSurface area of cuboid : ", result ," \n")
	end
end
def main()

	obj = Cuboid.new()
	# Simple Case
	obj.cuboid_surface_area(3.5, 5.5, 7.2)
	obj.cuboid_surface_area(2, 3, 5)
	obj.cuboid_surface_area(7, 5.4, 5)
end
main()

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.10000000000002 

Given Length : 2, Width : 3 , Height : 5
Surface area of cuboid : 62 

Given Length : 7, Width : 5.4 , Height : 5
Surface area of cuboid : 199.60000000000002 
// Scala Program
// Find surface area of cuboid
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	def cuboid_surface_area(length: Double, width: Double, height: Double): Unit = {
		print("\nGiven Length : " + length + ", Width : " + width + " , Height : " + height);
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		var result: Double = (2 * length * width) + (2 * length * height) + (2 * width * height);
		//Display result
		print("\nSurface area of cuboid : " + result + " \n");
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var obj: Cuboid = new Cuboid();
		//Simple Case
		obj.cuboid_surface_area(3.5, 5.5, 7.2);
		obj.cuboid_surface_area(2, 3, 5);
		obj.cuboid_surface_area(7, 5.4, 5);
	}
}

Output

Given Length : 3.5, Width : 5.5 , Height : 7.2
Surface area of cuboid : 168.10000000000002

Given Length : 2.0, Width : 3.0 , Height : 5.0
Surface area of cuboid : 62.0

Given Length : 7.0, Width : 5.4 , Height : 5.0
Surface area of cuboid : 199.60000000000002
// Swift Program
// Find surface area of cuboid
class Cuboid
{
	//Calculate surface area of cuboid by length,width and height
	func cuboid_surface_area(_ length: Double, _ width: Double, _ height: Double)
	{
		print("\nGiven Length : ", length ,", Width : ", width ," , Height : ", height, terminator: "");
		// Formula of cuboid surface area 
		// (2*length*width)+(2*length*height)+(2*width*height)
		// Calculate surface area of cuboid
		let result: Double = (2 * length * width) + (2 * length * height) + (2 * width * height);
		print("\nSurface area of cuboid : ", result ," \n", terminator: "");
	}
}
func main()
{
	let obj: Cuboid = Cuboid();
	//Simple Case
	obj.cuboid_surface_area(3.5, 5.5, 7.2);
	obj.cuboid_surface_area(2, 3, 5);
	obj.cuboid_surface_area(7, 5.4, 5);
}
main();

Output

Given Length :  3.5 , Width :  5.5  , Height :  7.2
Surface area of cuboid :  168.1

Given Length :  2.0 , Width :  3.0  , Height :  5.0
Surface area of cuboid :  62.0

Given Length :  7.0 , Width :  5.4  , Height :  5.0
Surface area of cuboid :  199.6


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved