Area Triangle Square Circle Rectangle coderinme

Area Triangle Square Circle Rectangle coderinme

Area of Triangle = 1/2 * base * height
Area of Square = side * side
Area of Circle = Pi * radiua * radius
Area of Rectanfle = length * breadth

Write a program to calculate the area of triangle, square, circle, rectangle by using method overloading.
Program:

public class Q15 
{
public static void main(String[] args) 
{
Area ar=new Area();
ar.triangle(3,4);
ar.squre(5);
ar.circle(2);
ar.rectangle(8,9);
}
}
class Area 
{
void triangle (float a, float b) 
{
System.out.println("The area of triangle is : "+((a*b)/2));
}
void squre (float a) 
{
System.out.println("The area of square is : "+(a*a));
}
void circle (float r) 
{
double PI=3.14;
System.out.println("The area of circle is : "+(PI*r*r));
}
void rectangle(float a, float b) 
{
System.out.println("The area of rectangle is : "+(a*b));
}
}

For more programs on Java, visit our Java Archives

Area Triangle Square Circle Rectangle

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.