import java.util.Scanner;
public class China {
public static void main(String[] args) {
int A,B,C;
boolean boo=true;
boolean boo2=true;
String demo;
Scanner input=new Scanner(System.in);
do{
System.out.printf("请输入需要相加的数:");
A=input.nextInt();
System.out.printf("请输入需要相加的数:");
B=input.nextInt();
C=A+B;
System.out.println(A+"和"+B+"相加的和是:"+C);
do{
System.out.println("是否继续?y/n");
demo = input.next();
if(demo.equals("y")||demo.equals("n")){
if(demo.equals("n")){
boo = false;
boo2= false;
}else if(demo.equals("y")){
boo=true;
boo2=false;
}
}else{
System.out.println("输入不正确,请重新输入!");
}
}while(boo2);
}while(boo);
}
}
把2楼的完善了一下