package com.my.demo; import java.util.Scanner; public class Triangle { public static void main(String[] args) { System.out.println("请输入三个正整数:"); Scanner sc1=new Scanner(System.in); int a=sc1.nextInt(); int b=sc1.nextInt(); int c=sc1.nextInt(); Triangle in = new Triangle(); if(a<=0||b<=0||c<=0) { System.out.println("输入的必须是正整数!"); } if((a+b)>c&&(a+c)>b&&(b+c)>a) { System.out.println("能够构成三角形!"); } else { System.out.println("不能构成三角形!"); } } }