範例程式 |
- Ex1_3.java
package chape; import java.io.*; public class Ex1_3 { public static void main(String[] args) throws IOException { int number1 = 0; int number2 = 0; System.out.print("請輸入第1個數字"); BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String s1 = bf.readLine(); number1 = Integer.parseInt(s1); System.out.print("請輸入第2個數字"); String s2 = bf.readLine(); number2 = Integer.parseInt(s2); System.out.println("你輸入的第1個數字是" + s1); System.out.println("你輸入的第2個數字是" + s2); System.out.println("2數相加=" + (number1 + number2)); } } |
沒有留言:
張貼留言