Help me with this program ( class 9)
if you spam i will report your account as well as your answer❌
1234
yup fast
Answers
Answer: The required java program is :-
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter first side of triangle : ");
int a = scan.nextInt();
System.out.print("Enter second side of triangle : ");
int b = scan.nextInt();
System.out.print("Enter third side of triangle : ");
int c = scan.nextInt();
scan.close();
double area = 0.0;
if((a+b)>c) {
if((b+c)>a) {
if((c+a)>b) {
if(a==b && b==c) {
area = (Math.sqrt(3)/2)*(Math.pow(a,2));
System.out.print("It is an equilateral triangle and its area is "+area+" sq. units.");
}
else if((Math.pow(a,2)+Math.pow(b,2))==Math.pow(c,2)) {
area = 0.5*a*b;
System.out.println("It is a right-angled triangle and its area is "+area+" sq. units.");
}
else if((Math.pow(b,2)+Math.pow(c,2))==Math.pow(a,2)) {
area = 0.5*b*c;
System.out.println("It is a right-angled triangle and its area is "+area+" sq. units.");
}
else if((Math.pow(c,2)+Math.pow(a,2))==Math.pow(b,2)) {
area = 0.5*c*a;
System.out.println("It is a right-angled triangle and its area is "+area+" sq. units.");
}
else {
double s = (double)(a+b+c)/2;
area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("The area of triangle is "+area+" sq. units.");
}
}
else {
System.out.println("A triangle cannot be formed.");
}
}
else {
System.out.println("A triangle cannot be formed.");
}
}
else {
System.out.println("A triangle cannot be formed.");
}
}
}
Input :-
Enter first side of triangle : 3
Enter second side of triangle : 6
Enter third side of triangle : 8
Output :-
The area of triangle is 7.644442425710328 sq. units.
Input :-
Enter first side of triangle : 3
Enter second side of triangle : 3
Enter third side of triangle : 3
Output :-
It is an equilateral triangle and its area is 7.794228634059947 sq. units.
Input :-
Enter first side of triangle : 3
Enter second side of triangle : 4
Enter third side of triangle : 5
Output :-
It is a right-angled triangle and its area is 6.0 sq. units.
Input :-
Enter first side of triangle : 1
Enter second side of triangle : 2
Enter third side of triangle : 3
Output :-
A triangle cannot be formed.
Note :-
The above program is stored in file named Main.java
Also, try-catch block can be used to avoid any type of error.
Answer:
please I am sorry please give ur number I tell u reasons lpease dear friend