import java.util.Scanner;
public class Number {
public static void test() {
Scanner sc = new Scanner(System.in);
int num = 0;
System.out.println("是否继续 1.继续 2.退出");
num = sc.nextInt();
if (num == 1) {
System.out.println("请输入三角形三条边:");
int a, b, c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
test();
} else {
System.out.println("已退出");
}
}
public static void main(String[] args) {
test();
}
}
大概的结构是这样子,代码可以自己往里面填
最外层再套一层循环
boolean flag = true;
while(flag){
.......
if(......){
}else{
System.out.println("是否继续输入:1 、是 2、否");
int d = sc.nextInt();
if(d!=1) {
flag = false;
}
}
}