我的代码如下。我期待它吐出类似的东西:
SN=12345678 EX= 73 CW= 73 标记 = 73.0
SN=87654321 EX= 50 CW= 70 标记 = 60.0
但我得到:
.
.
.
SN=12345678 EX= 73 CW= 73 标记 = 73.0
.
.
SN=87654321 EX= 50 CW= 70 标记 = 60.0
(带有大量额外的换行符(由句点显示))
我真的不知道这些是从哪里来的。
请指出我正确的方向!
class Main
{
public static void main( String args[] )
{
int sN = 1;
int cwMark;
int exMark;
double Mark;
while ( sN != 0 )
{
sN = CIO.getInt();
cwMark = CIO.getInt();
exMark = CIO.getInt();
Mark = ((double)(exMark + cwMark)/2);
System.out.print("SN=");
System.out.print( (int) sN );
System.out.print(" EX= ");
System.out.print( (int) exMark );
System.out.print(" CW= ");
System.out.print( (int) cwMark );
System.out.print(" Mark = ");
System.out.print(Mark);
}
}
}
getInt 定义为:
public static int getInt()
{
String res = getLine();
int value = 0;
try
{
value = Integer.parseInt( res.trim() );
}
catch ( NumberFormatException ex )
{
}
return value;
}