Finding Triangle with Three lengths in Java 2024 - Java Technical Interview

 Finding Triangle with Three length

        We are going to find which Triangle's side this are using Java.

1. We are check three Triangle, which is Equilateral, Isosceles and Scalene.

2. First we need to know the Mathmetical logic for all this,

    Equilateral ==> all the three length's are equal.

    Isosceles ==> either two side's are equal

    Scalene ==> all three side's are different

3. Final part is we need to implement this in code.


Code : 

package com.dinatechy.challange;


public class FindWhichTriangle {

public static void main(String[] args) {

// Find the Which Triangle based on the given Three length's

// Equilateral == all the three lenght's are equal,

// Isosceles == either two side's are equal or

// Scalene == all three side's are different

int a = 23, b = 231, c = 232;

if( a==b && b==c && c==a )

System.out.println("Equilateral");

else if( a==b || b==c || c==a )

System.out.println("Isosceles");

else if( a!=b && b!=c && c!=a )

System.out.println("Scalene");

}


}

Scenario 1 :

Input :

a = 23, b = 231, c = 232

Output :

Scalene

Scenario 2 :

Input :

a = 23, b = 23, c = 232

Output :

Isosceles

Scenario 3 :

Input :

a = 23, b = 23, c = 23

Output :

Equilateral

Follow us for more useful programs daily and subscribe to my Youtube channel - DinaTechy....

Comments

Popular posts from this blog

Finding Second largest number in Array - Java - TCS - Technical Interview

Checking Character only in String - Java 2024 - MNC - Technical Interview

Object Class in Java | Article | Solution Maker - Blog