Skip to content

Commit 8a198ff

Browse files
committed
feat: Add Expression2 class to calculate triangle area using Heron's formula
Add a program that: - Takes three side lengths of a triangle as input - Computes the semi-perimeter (s) and area using Heron’s formula - Uses `Math.sqrt` for square root calculation - Demonstrates use of arithmetic expressions, type casting, and user input in Java.
1 parent 8a35d15 commit 8a198ff

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import java.lang.*;
22
import java.util.Scanner;
33

4-
class Expression2
5-
{
6-
public static void main(String args[])
7-
{
4+
class Expression2 {
5+
public static void main(String args[]) {
86
Scanner sc=new Scanner(System.in);
97
int a, b, c;
10-
float s;
8+
float s; //initialize the variable to store the value.
119
double area;
1210

1311
System.out.println("Enter 3 sides of a triangle ");
@@ -21,4 +19,4 @@ public static void main(String args[])
2119

2220
System.out.println("area is "+ area);
2321
}
24-
}
22+
}

0 commit comments

Comments
 (0)