Find the area of ellipse

Here given code implementation process.

//C Program
//Find the area of ellipse
#include <stdio.h>

#include <math.h>
 //Calculate area of ellipse by given axis
void ellipse_area(double x_axis, double y_axis)
{
	//Calculate Formula
	//Major and Minor Axis
	//π*(x_axis * y_axis)
	double area = (M_PI) * (x_axis * y_axis);
	//Display the result of ellipse area
	printf(" Ellipse  [ X-axis : %lf, Y-axis %lf] ", x_axis, y_axis);
	printf("\n Area : %lf\n\n", area);
}
int main()
{
	//Test Cases  
	ellipse_area(4, 3);
	ellipse_area(7, 5);
	ellipse_area(7.4, 4.2);
	return 0;
}

Output

 Ellipse  [ X-axis : 4.000000, Y-axis 3.000000]
 Area : 37.699112

 Ellipse  [ X-axis : 7.000000, Y-axis 5.000000]
 Area : 109.955743

 Ellipse  [ X-axis : 7.400000, Y-axis 4.200000]
 Area : 97.640700
// Java Program
// Find the area of ellipse
class EllipseArea
{
	//Calculate area of ellipse by given axis
	public void ellipse_area(double x_axis, double y_axis)
	{
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis * y_axis)
		double area = (Math.PI) * (x_axis * y_axis);
		//Display the result of ellipse area
		System.out.print(" Ellipse [ X-axis : " + x_axis + ", Y-axis " + y_axis + "] ");
		System.out.print("\n Area : " + area + "\n\n");
	}
	public static void main(String[] args)
	{
		EllipseArea obj = new EllipseArea();
		//Test Cases  
		obj.ellipse_area(4, 3);
		obj.ellipse_area(7, 5);
		obj.ellipse_area(7.4, 4.2);
	}
}

Output

 Ellipse [ X-axis : 4.0, Y-axis 3.0]
 Area : 37.69911184307752

 Ellipse [ X-axis : 7.0, Y-axis 5.0]
 Area : 109.95574287564276

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.64069967357078
// C++ Program
// Find the area of ellipse
#include<iostream>
#include<math.h>
using namespace std;
class EllipseArea
{
	public:
		//Calculate area of ellipse by given axis
		void ellipse_area(double x_axis, double y_axis)
		{
			//Calculate Formula
			//Major and Minor Axis
			//π*(x_axis *y_axis)
			double area = (M_PI) *(x_axis *y_axis);
			cout << " Ellipse [ X-axis : " << x_axis << ", Y-axis " << y_axis << "] ";
			cout << "\n Area : " << area << "\n\n";
		}
};
int main()
{
	EllipseArea obj = EllipseArea();
	//Test Cases  
	obj.ellipse_area(4, 3);
	obj.ellipse_area(7, 5);
	obj.ellipse_area(7.4, 4.2);
	return 0;
}

Output

 Ellipse [ X-axis : 4, Y-axis 3]
 Area : 37.6991

 Ellipse [ X-axis : 7, Y-axis 5]
 Area : 109.956

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.6407
// C# Program
// Find the area of ellipse
using System;
class EllipseArea
{
	//Calculate area of ellipse by given axis
	public void ellipse_area(double x_axis, double y_axis)
	{
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis * y_axis)
		double area = (Math.PI) * (x_axis * y_axis);
		Console.Write(" Ellipse [ X-axis : " + x_axis + ", Y-axis " + y_axis + "] ");
		Console.Write("\n Area : " + area + "\n\n");
	}
	public static void Main(String[] args)
	{
		EllipseArea obj = new EllipseArea();
		//Test Cases  
		obj.ellipse_area(4, 3);
		obj.ellipse_area(7, 5);
		obj.ellipse_area(7.4, 4.2);
	}
}

Output

 Ellipse [ X-axis : 4, Y-axis 3]
 Area : 37.6991118430775

 Ellipse [ X-axis : 7, Y-axis 5]
 Area : 109.955742875643

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.6406996735708
<?php
// Php Program
// Find the area of ellipse
class EllipseArea
{
	//Calculate area of ellipse by given axis
	public 	function ellipse_area($x_axis, $y_axis)
	{
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis *y_axis)
		$area = (M_PI) *($x_axis *$y_axis);
		//Display the result of ellipse area
		echo(" Ellipse [ X-axis : ". $x_axis .", Y-axis ". $y_axis ."] ");
		echo("\n Area : ". $area ."\n\n");
	}
}

function main()
{
	$obj = new EllipseArea();
	//Test Cases  
	$obj->ellipse_area(4, 3);
	$obj->ellipse_area(7, 5);
	$obj->ellipse_area(7.4, 4.2);
}
main();

Output

 Ellipse [ X-axis : 4, Y-axis 3]
 Area : 37.699111843078

 Ellipse [ X-axis : 7, Y-axis 5]
 Area : 109.95574287564

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.640699673571
// Node Js Program
// Find the area of ellipse
class EllipseArea
{
	//Calculate area of ellipse by given axis
	ellipse_area(x_axis, y_axis)
	{
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis *y_axis)
		var area = (Math.PI) *(x_axis *y_axis);
		//Display the result of ellipse area
		process.stdout.write(" Ellipse [ X-axis : " + x_axis + ", Y-axis " + y_axis + "] ");
		process.stdout.write("\n Area : " + area + "\n\n");
	}
}

function main(args)
{
	var obj = new EllipseArea();
	//Test Cases  
	obj.ellipse_area(4, 3);
	obj.ellipse_area(7, 5);
	obj.ellipse_area(7.4, 4.2);
}
main();

Output

 Ellipse [ X-axis : 4, Y-axis 3]
 Area : 37.69911184307752

 Ellipse [ X-axis : 7, Y-axis 5]
 Area : 109.95574287564276

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.64069967357078
#  Python 3 Program
#  Find the area of ellipse
import math
class EllipseArea :
	# Calculate area of ellipse by given axis
	def ellipse_area(self, x_axis, y_axis) :
		# Calculate Formula
		# Major and Minor Axis
		# π*(x_axis * y_axis)
		area = (math.pi) * (x_axis * y_axis)
		# Display the result of ellipse area
		print(" Ellipse [ X-axis : ", x_axis ,", Y-axis ", y_axis ,"] ")
		print(" Area : ", area ,"\n")
	

def main() :
	obj = EllipseArea()
	# Test Cases  
	obj.ellipse_area(4, 3)
	obj.ellipse_area(7, 5)
	obj.ellipse_area(7.4, 4.2)


if __name__ == "__main__": main()

Output

 Ellipse [ X-axis :  4 , Y-axis  3 ]
 Area :  37.69911184307752

 Ellipse [ X-axis :  7 , Y-axis  5 ]
 Area :  109.95574287564276

 Ellipse [ X-axis :  7.4 , Y-axis  4.2 ]
 Area :  97.64069967357078
#  Ruby Program
#  Find the area of ellipse
class EllipseArea

	# Calculate area of ellipse by given axis
	def ellipse_area(x_axis, y_axis)
	
		# Calculate Formula
		# Major and Minor Axis
		# π*(x_axis * y_axis)
		area = (Math::PI) * (x_axis * y_axis)
		# Display the result of ellipse area
		print(" Ellipse [ X-axis  :", x_axis ,", Y-axis ", y_axis ,"] ")
		print("\n Area  :", area ,"\n\n")
	end
end
def main()

	obj = EllipseArea.new()
	# Test Cases  
	obj.ellipse_area(4, 3)
	obj.ellipse_area(7, 5)
	obj.ellipse_area(7.4, 4.2)
end
main()

Output

 Ellipse [ X-axis  :4, Y-axis 3] 
 Area  :37.69911184307752

 Ellipse [ X-axis  :7, Y-axis 5] 
 Area  :109.95574287564276

 Ellipse [ X-axis  :7.4, Y-axis 4.2] 
 Area  :97.64069967357078

// Scala Program
// Find the area of ellipse
class EllipseArea
{
	//Calculate area of ellipse by given axis
	def ellipse_area(x_axis: Double, y_axis: Double): Unit = {
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis * y_axis)
		var area: Double = (Math.PI) * (x_axis * y_axis);
		//Display the result of ellipse area
		print(" Ellipse [ X-axis : " + x_axis + ", Y-axis " + y_axis + "] ");
		print("\n Area : " + area + "\n\n");
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var obj: EllipseArea = new EllipseArea();
		//Test Cases  
		obj.ellipse_area(4, 3);
		obj.ellipse_area(7, 5);
		obj.ellipse_area(7.4, 4.2);
	}
}

Output

 Ellipse [ X-axis : 4.0, Y-axis 3.0]
 Area : 37.69911184307752

 Ellipse [ X-axis : 7.0, Y-axis 5.0]
 Area : 109.95574287564276

 Ellipse [ X-axis : 7.4, Y-axis 4.2]
 Area : 97.64069967357078
// Swift Program
// Find the area of ellipse
class EllipseArea
{
	//Calculate area of ellipse by given axis
	func ellipse_area(_ x_axis: Double, _ y_axis: Double)
	{
		//Calculate Formula
		//Major and Minor Axis
		//π*(x_axis * y_axis)
		let area: Double = (Double.pi) * (x_axis * y_axis);
		//Display the result of ellipse area
		print(" Ellipse [ X-axis : ", x_axis ,", Y-axis ", y_axis ,"] ", terminator: "");
		print("\n Area : ", area ,"\n\n", terminator: "");
	}
}
func main()
{
	let obj: EllipseArea = EllipseArea();
	//Test Cases  
	obj.ellipse_area(4, 3);
	obj.ellipse_area(7, 5);
	obj.ellipse_area(7.4, 4.2);
}
main();

Output

 Ellipse [ X-axis :  4.0 , Y-axis  3.0 ]
 Area :  37.6991118430775

 Ellipse [ X-axis :  7.0 , Y-axis  5.0 ]
 Area :  109.955742875643

 Ellipse [ X-axis :  7.4 , Y-axis  4.2 ]
 Area :  97.6406996735708


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