int a = 0, b = 0, c = 0, max;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
System.out.println("请输入第一个数:");
a = Integer.parseInt(br.readLine());
System.out.println("请输入第二个数:");
b = Integer.parseInt(br.readLine());
System.out.println("请输入第三个数:");
c = Integer.parseInt(br.readLine());
} catch (IOException e) {
}
max = a;
if (b > max)
max = b;
if (c > max)
max = c;
System.out.println("最大数为:" + max);
}
三处都使用 Integer.parseInt(br.readLine());
如果使用 br.read() 只能在输入第一个数后就运行完了。
那么第二个数和第三个数将无法输入。是比较不出的。
a= Integer.parseInt(br.readLine());
b= Integer.parseInt(br.readLine());
c= Integer.parseInt(br.readLine());
br.read()
3个空都是这个
JAVA语言I/O输入输出的一个练习题目,我根本看不懂,请帮我做一下,谢谢了,实在感谢 50分!!!~
public static void main(String[] args) {
// 路径可以换,这里是绝对路径
File src = new File("d:/source.txt");
File aim = new File("d:/aim.txt");
try {
// 文件不存在则新建
if (!aim.exists()) {
aim.createNewFile();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
// 针对src文件的扫描器
Scanner sca = new Scanner(src);
// 针对aim文件 PrintWriter
PrintWriter writer = new PrintWriter(aim);
while (sca.hasNext()) {
// 读取一行
String line = sca.nextLine();
// 转换为大写
line = line.toUpperCase();
// 写入aim文件中
writer.println(line);
}
// 关闭写入器
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
我知道怎么做。。我已经 百度hi你了。
代码行数:304
注释行数:2
空行行数:12
文件个数:7
#13635026598#
紧急求助:全国计算机等级考试二级Java上机步骤 - ******
#滑婷# 首先,不运行的状态交卷算做此题不得分. 其次,(vfp,Java,C)机试好像都是采用:一改错(3-4个),二填空(3-4),三编程(一道程序).希望对你有帮助.
#13635026598#
高分求JAVA高手解决一个题目!! - ******
#滑婷# import java.io.IOException;public class Calculate { private String inputDatas[] = {"zero","one","two","three","four","five", "six","seven","eight","nine"}; private String resultStr = ""; public String getInputData(){ String data=...
#13635026598#
跪求答案,高手请进,要这几道JAVA答案.马上要来考试~~! 谢谢了~! - ******
#滑婷# 第一题 : import java.util.ArrayList; import java.util.List;class Vehicle {public void run(){System.out.println("这是交通工具run方法");} } class Motor extends Vehicle{public void run(){System.out.println("这是Motorrun方法");} } ...
#13635026598#
用Java语言编写在线考试系统 ******
#滑婷# 哪个不是很难 用J2EE 一个Tomcat做服务器 如果想做简单的 自己用JAVA.NET包里的知识开发个自己的小型服务器也是可以的
#13635026598#
JAVA程序设计 考题 高分求助 - ******
#滑婷# 不知道楼主要什么样的,我现做了一个,不知道是不是符合要求,有问题,请提.代码如下:public class L { public static void main(String[] args) { FS f = new FS(); f.In1(1.0, "2.0i"); f.In2(3.0, "5.0i"); f.JaFa(); f.In1(3.0, "5.0i"); f.In2(1.0, "2.0...
#13635026598#
急,高分求java高手帮忙!!! ******
#滑婷# public class ArrayTest{ public static void main(String args[]) { int num,i,m,n=4,index,a=0,temp;//定义变量 int array[][]; array=new int[n][n];//定义4行4列数组 index=n; m=num=0; temp=1;//赋初值 for(i=1;i<2*n;i++)//i是控制走回形路线的变量,即i=...
#13635026598#
一道简单的JAVA题目 在线等高分 - ******
#滑婷# 第五个问题应该要写个 排序的方法 你自己研究去吧!import java.util.LinkedList; import java.util.List; public class Student { private int id; // 学号 private String name; // 姓名 private int age; // 年龄 private int sex; // 性别 0,女;1,男 List ...
#13635026598#
java二级上机考试的操作平台是什么 - ******
#滑婷# 如果很正规的话,就是Linux,不正规就是Windows
#13635026598#
全国计算机等级考试上机考试题库二级Java序列号”这个问题没有说java的序列号啊!麻烦你了 ******
#滑婷# 三级网络 安装注册码:786-298-784 301699990001 二级VFP语言 安装注册码:678-164-393 2916999900001 二级 c++ 安装注册码:786-182-336 二级VB语言 安装注册码:213-588-733 281699990001 三级网络 安装注册码:786-298-784 ...
#13635026598#
高分求JAVA高手编程,坐等高人.~~~~ - ******
#滑婷# import java.util.Scanner;public class Test { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); System.out.println("输入体重"); double weight=scanner.nextDouble(); System.out.println("输入身高"); ...