- 1

Java program to take input of three sides of a triangle using standard input dialogue box compute the area of the triangle.

Write a Java program to take input of three sides of a triangle using standard input dialogue box compute the area of the triangle so the output using message dialogue box

7th Apr 2021, 5:36 AM
Kamalesh Ray
4 odpowiedzi
- 1
import javax.swing.JOptionPane; public class TriangleTest { public static void main(String[] args) { String input; int s1, s2, s3; input = JOptionPane.showInputDialog("Enter s1"); s1 = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter s2"); s2 = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter s2"); s3 = Integer.parseInt(input); if((s1+s2)>s3 && (s1+s3)>s2 && (s2+s3)>s1) { int s=(s1+s2+s3)/2; double area=Math.sqrt(s*(s-s1)*(s-s2)*(s-s3)); JOptionPane.showMessageDialog(null,"Area of triangle is " + area); } else JOptionPane.showMessageDialog(null,"Triangle is not valid"); } }
7th Apr 2021, 8:33 AM
Kamalesh Ray
+ 2
Seems to be your homework. Anyways post your code here
7th Apr 2021, 5:45 AM
Atul [Inactive]
0
Show. Your. Attempt.
7th Apr 2021, 5:37 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar