hello. i have just started learning functions in java. i have done the below program to find area of rectangle,triangle and square. it is a private class.
class calcu
{
void rectangle(int l,int b)
{
int area1;
area1=l*b;
System.out.println("area of rectangle = "+area1);
}
void triangle(double base,double h)
{
double area2;
area2=(0.5)*base*h;
System.out.println("area of trinagle = ="+area2);
}
void square(int len)
{
int area3;
area3=len*len;
System.out.println("area of square = ="+area3);
}
public static void main(int m,int n,double o,double p,int q)
{
int a,d;
double c;
calcu obj=new calcu();
a=obj.rectangle(m,n);
c=obj.triangle(o,p);
d=obj.square(q);
}}
when i compile this program, i get an error that "incompatible types-found void but expected int".can anyone say what mistake i have done?