java控制台输入回车问题
程序代码:
import java.util.*; class Student{ String stuno; String name; float math; float english; float computer; /*public Student(){ } public Student(String stuno,String name,float math,float english,float computer){ this.setStuno(stuno); this.setName(name); this.setMath(math); this.setEnglish(english); this.setComputer(computer); }*/ public void setStuno(String s){ stuno=s; } public void setName(String n){ name=n; } public void setMath(float m){ math=m; } public void setEnglish(float e){ english=e; } public void setComputer(float c){ computer=c; } public String getStuno(){ return stuno; } public String getName(){ return name; } public float getMath(){ return math; } public float getEnglish(){ return english; } public float getComputer(){ return computer; } public float sum(){ return math+english+computer; } public float avg(){ return sum()/3; } public float max(){ return Math.max(Math.max(math, english),computer); } public float min(){ return Math.min(Math.min(math, english),computer); } public void tell(){ System.out.println("学生学号:"+getStuno()); System.out.println("学生姓名:"+getName()); System.out.println("数学成绩:"+getMath()); System.out.println("英语成绩:"+getEnglish()); System.out.println("计算机成绩:"+getComputer()); System.out.println("总分:"+sum()); System.out.printf("平均分:%.1f\n",avg()); System.out.println("最高分:"+max()); System.out.println("最低分:"+min()); } } public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); Student st1=new Student(); String s=cin.next(); String n=cin.next(); float m=cin.nextFloat(); float e=cin.nextFloat(); float c=cin.nextFloat(); st1.setStuno(s); st1.setName(n); st1.setMath(m); st1.setEnglish(e); st1.setComputer(c); st1.tell(); } }
输入
01 李星 95.0 89.0 96.0
输出
学生学号:01
学生姓名:李星
数学成绩:95.0
英语成绩:89.0
计算机成绩:96.0
总分:280.0
平均分:93.3
最高分:96.0
最低分:89.0
结果总是要回车一下才能输出,java控制台输入时不能回车的吧,应该怎样改呢,谢谢