Page 137 - CA_Blue( J )_Class9
P. 137
You will get the following output:
Program 5 Write a program to display the area of a triangle using Heron's formula.
1 import java.io.*;
2 class Program5
{
3
4 public static void main(String args[])throws IOException
5 {
InputStreamReader isr = new InputStreamReader(System.in);
6
BufferedReader br= new BufferedReader(isr);
7
8 int a,b,c;
9 double s,ar;
10 System.out.println("Enter three sides of a triangle :");
11 a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
12
c=Integer.parseInt(br.readLine());
13
s=(a+b+c)/2.0;
14
15 ar= Math.sqrt(s*(s-a)*(s-b)*(s-c));
16 System.out.println("Area of triangle "+ar);
}
17
}
18
Input in Java 135

