Computer Science, asked by Aaditiyadav, 1 year ago

Plzzz help me with this Java program

Attachments:

Answers

Answered by gauravrai2002
1
import java.io.*;
class area
{
public static void main (String args[])throws IOException
{
InputStreamReader read = new InputStreamReader ( System.in);

BufferedReader in = new BufferedReader(read);

int op,
double ar=0.0

System.out.println("Enter the three sides of a triangle");
a= Integer.parseInt(in.readLine);
b=Integer.parseInt(in.readLine);
c=Integer.parseInt(in.readLine);
System.out.println("enter 1 for equilateral triangle");
System.out.println("enter 2 for isosceles triangle");
System.out.println("enter 3 for scalene triangle");
op=Integer.parseInt(in.readLine);
switch (op)
{
case 1: ar = (Math.sqrt(3)/4)*(a*a);
System.out.println("area ="+ar);
break;

case 2: if(a=b)
{
ar=(1/4)*c*(Math.sqrt((4*a*a)-(c*c)));
System.out.println("area ="+ar);
}
if(a=c)
{
ar=(1/4)*b*(Math.sqrt((4*a*a)-(b*b)));
System.out.println("area ="+ar);
}
if(c=b)
{
ar=(1/4)*a*(Math.sqrt((4*b*b)-(a*a)));
System.out.println("area ="+ar);
}
break;

case 3: s= a+b+c;
ar =Math.sqrt((s*(s-a)*(s-b)*(s-c)));
System.out.println("area ="+ar);
break;

default: System.out.println("Wrong choice");
break;
}
}
}
Similar questions