Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Chap3_19PerimeterOfTriangle {
- public static void main(String[] args) {
- Scanner kb = new Scanner(System.in);
- System.out.println("Enter the 3 segment lengths");
- // get user input
- int a = kb.nextInt();
- int b = kb.nextInt();
- int c = kb.nextInt();
- // sum of any two sides must be greater than the 3rd side
- if ((a+b)<= c || (a+c)<= b || (b+c)<=a)
- System.out.println("this could not form a triangle");
- else
- System.out.println("The perimeter is "+ (a+b+c));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement