Example
Input
5 8 5
Output
Issoceles
Required to Know
Use of Variables, Use of different operators like assignment or arithmetic operators, Use of methods like System. out. print(), and use of if else, and Use of Data types
Steps
This program determines the type of a triangle based on the length of its sides. Here's a breakdown of how it works:
The program starts by importing the Scanner class, which is used to read user input.
The main method is where the program execution begins. It creates a new Scanner object to read user input and then reads in the lengths of the triangle's three sides.
The program then uses a series of if-else statements to determine the type of the triangle:
If all three sides are equal, the triangle is equilateral.
If any two sides are equal, the triangle is isosceles.
If no two sides are equal, the triangle is scalene.
Program
import java.util.Scanner;
public class Mavenproject1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int side1,side2, side3;
side1 = sc.nextInt();
side2 = sc.nextInt();
side3 = sc.nextInt();
if(side1==side2&& side2==side3){
System.out.print("Equilateral");
}
else if(side1==side2 || side1==side3 || side2==side3){
System.out.print("Issoceles");
}
else{
System.out.print("Scalene");
}
}
}