填空题

[说明] 编写一个Application,从键盘输入整数n,并计算从1到n的累加和。 import java. io. *; public class Application1 { public static void main(String [] args) { String s = " "; int n, sum = 0; System. out. println (“计算从1到n 的累加和。”); System. out. print( “请输入n的值:”); try { (1) BufferedReader br = new BufferedReader(isr); (2) } catch(Exception e) { } (3) for(int i=l; i< =n; i++) (4) System. out. println ( “你刚才的输入是:” + n); System. out. println ( “1到n的累加和是:”+ sum); } }

【参考答案】

InputStreamReader isr = new InputStreamReader ( System. in);