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

Check Triangle is Valid or Not When Angles are given

Article:
Viewed:  1098 
Posted On:  24/07/2013 03:49:44 
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 for the given angles by the user or not a valid triangle.................. 

 

Below is my code:


import java.util.Scanner;
class triangle
{
public static void main(String s[])
{
int a,b,c,d;
System.out.println("enter 1 angle of triangle ");
Scanner scan=new Scanner(System.in);
a=scan.nextInt();
System.out.println("you entered ="+a);
System.out.println("enter 2 angle of triangle");
Scanner scan1=new Scanner(System.in);
b=scan1.nextInt();
System.out.println("you entered ="+b);
System.out.println("enter 3 angle of triangle");
Scanner scan2=new Scanner(System.in);
c=scan2.nextInt();
System.out.println("you entered ="+c);
d=a+b+c;
if(d==180)
{
System.out.println("triangle is valid");
}
else
{
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 trianglee.java
  
  Step 2 : Open command prompt 
   
  Step 3 : Write javac trianglee.java - Press Enter for compilation

        Step 4 : Write java triangle for execution

Output:

Triangle.png

Image 1.

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