diff --git "a/34 \351\230\216\345\206\240\345\256\207/20230510 \345\274\202\345\270\270.md" "b/34 \351\230\216\345\206\240\345\256\207/20230510 \345\274\202\345\270\270.md" new file mode 100644 index 0000000000000000000000000000000000000000..8c6f43ee132695ac6bd784640fef9e63d894a624 --- /dev/null +++ "b/34 \351\230\216\345\206\240\345\256\207/20230510 \345\274\202\345\270\270.md" @@ -0,0 +1,26 @@ +```java +import java.util.Scanner; +public class Demo { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + while (true) { + try { + System.out.print("请输入a的值:"); + int a= sc.nextInt(); + System.out.print("请输入b的值:"); + int b= sc.nextInt(); + System.out.println("a+b的值是:"+sum(a,b)); + break; + } catch (Exception e) { + System.out.println("请重新输入!"); + sc.next(); + } + } + } + public static int sum(int a,int b){ + return a+b; + } +} +``` +