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
#19488433469#
高分求道Java题 ******
#牧柔#import java.lang.reflect.Method; import org.springframework.aop.AfterReturningAdvice; public class AfterAdvice implements AfterReturningAdvice{ public void afterReturning(Object returnValue ,Method method, Object[] args,Object target) throws ...
#19488433469#
跪求答案,高手请进,要这几道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方法");} } ...
#19488433469#
计算机二级java机试环境?? - ******
#牧柔# 没考过二级,没猜错的话应该是打开程序-运行-输入cmd-进入dos-看java装在哪个盘-输入javac 貌似楼主也是个高手哇....
#19488433469#
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...
#19488433469#
急,高分求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=...
#19488433469#
高分求解, Java 作业题,各位高手能否帮忙看一下? - ******
#牧柔# package calculate; public class Calculate { private double interest; private double loanTerm; private double loanAmount; public Calculate(double interest, double loanTerm, double loanAmount) { this.interest = interest; this.loanTerm = loanTerm; this....
#19488433469#
求计算机二级考试java的试题 - ******
#牧柔# 老考生:笔 试:90 分钟; 上机操作:90 分钟.新考生:全部上机操作:120 分钟 从2013年3月开始,实施二级无纸化考试 如果是2013年3月以前的老考生,需要有笔试题,新考生全部无纸化考试,全部上机 没有笔式 只有选择题和上机题 上机题要求要用netbeans来做,考试的电脑上会装 这几个上机题都是netbeans的项目,考试的时候导入,这几个项目会有错误,要求你改正错误并能正常运行 考试 很简单,我有一个拟真考试软件的帐号,买来发现P也没用,基本上闭着眼都能80分,你要的话直接送你了 考过要求要有一定的java基本知识,和电脑的基本知识,最好你下个netbeans来做上机题,来熟悉上机环境,然后基本上就过了
#19488433469#
高分求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("输入身高"); ...
#19488433469#
高分求解 JAVA高手们进 ******
#牧柔#public class CountString { public static void main(String args[]) { String s = "SunfgjfjjJavahffgfhpJavaokJava%% ))()(&^%helloJavago1456461odJava"; String s1 = "Java"; countLetter(s); countAlphabet(s); System.out.println(s + "中出现了" + ...
#19488433469#
一道简单的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 ...