Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

Check triangle is valid or not when sides are given

Viewed:  1772 
Posted On:  24/07/2013 03:48:29 
Hi all,With the help of this article i am going to tell you that how we can find out that the triangle is valid or not when sides are givenby the user ..................... 


Below is my code:

import java.util.Scanner;
class triangle
public static void main(String s[])
int a,b,c;
System.out.println("enter 1 side of triangle ");
Scanner scan=new Scanner(;
System.out.println("you entered ="+a);
System.out.println("enter 2 side of triangle");
Scanner scan1=new Scanner(;
System.out.println("you entered ="+b);
System.out.println("enter 3side of triangle");
Scanner scan2=new Scanner(;
System.out.println("you entered ="+c);
System.out.println("triangle is valid");
else if(b>a+c)
System.out.println("triangle is valid");
else if(c>b+a)
System.out.println("triangle is valid");
System.out.println("triangle is invalid");

  Step 1:
  After writing this in notepad save the file with the name followed by (.java) for eg. I saved it with
          Step 2 : 
Open command prompt 

  Step 3
: Write javac - Press Enter for compilation

  Step 4 : 
Write java triangle for execution


Triangle Valid Side.png

Image 1.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us