#I wrote this program for the question given but the values of f and g are not being printed.

4 messages · Page 1 of 1 (latest)

sweet mountain
#

//4.WRITE A PROGRAM USING A FUNCTION OVERLOADING TECHNIQUE THAT COMPUTES AND DISPLAYS
//THE AREA OF A PARALLELOGRAM, A RHOMBUS AND A TRAPEZIUM.

import java.util.*;
public class Calculate

{
public static void main()
{
Scanner sc = new Scanner(System.in);
Calculate obj = new Calculate();
int a,b,e;
double a1,b1,f;
double a2,b2,c2,g;
System.out.println("Enter the length and breadth of the parallelogram");
a=sc.nextInt();
b=sc.nextInt();
System.out.println("Enter the diagonals of rhombus");
a1=sc.nextInt();
b1=sc.nextInt();
System.out.println("Enter the length of the two non parallel sides of the parallelogram and its height");
a2=sc.nextInt();
b2=sc.nextInt();
c2=sc.nextInt();
e=obj.area(a,b);
f=obj.area(a1,b1);
g=obj.area(a2,b2,c2);
System.out.println("The area of the Parallelogram="+e);
System.out.println("The area of the Rhombus="+f);
System.out.println("The area of the Trapezium="+g);

}

static int area(int a, int b)
{
    return(a*b);
}
static double area(double a, double b)
{
    return(1/2*(a*b));
}
static double area(double a, double b, double c)
{
    return(1/2*(a+b)*c);
}

}

mint laurelBOT
#

This post has been reserved for your question.

Hey @sweet mountain! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

mint laurelBOT