大学JAVA考试的一道简单的题目 求答案
WriteaJavaprogram(nameitIO.java)todothefollowingtasks:1)Promptstheusertoinputtwointeg...
Write a Java program(name it IO.java) to do the following tasks:
1) Prompts the user to input two integers.
2) Create a text file named "sum.txt" at the current dictionary.
3) Compute and write the sum of the two integers in the "sum.txt" file.
What is the output of the following program?程序的输出是什么
public class Test {
public static void main(String[] args) {
int a = 11; int b = 8;
int temp = b; b = a; a = temp;
System.out.println( a );
System.out.println( b );
}
}
最后一题了 求答案 a=? b=? 展开
1) Prompts the user to input two integers.
2) Create a text file named "sum.txt" at the current dictionary.
3) Compute and write the sum of the two integers in the "sum.txt" file.
What is the output of the following program?程序的输出是什么
public class Test {
public static void main(String[] args) {
int a = 11; int b = 8;
int temp = b; b = a; a = temp;
System.out.println( a );
System.out.println( b );
}
}
最后一题了 求答案 a=? b=? 展开
2个回答
展开全部
public class IO {
public static void main(String[] args) throws Exception {
Scanner scn = new Scanner(System.in);
System.out.println("please input to integers: ");
int result = scn.nextInt() + scn.nextInt();
new FileOutputStream("sum.txt").write(String.valueOf(result).getBytes());
}
}
更多追问追答
追问
请问能用eclipse调试过成功了吗 我考试用eclipse这个软件的
追答
肯定能啊,放心吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询