import java.io.*;public class FloatIn { public static void main(String[] args)throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String s; int t; s=stdin.readLine(); t=s.indexOf("."); System.out.println( "the integer part is: " + s.substring(0,t)); System.out.println( "the decimal part is: " + s.substring(t+1)); } }保险起见可以先判断是否为浮点数
本人刚学JAVA 菜得很
public static void main(String[] args)throws IOException {
BufferedReader stdin = new
BufferedReader(new
InputStreamReader(System.in));
String s;
int t;
s=stdin.readLine();
t=s.indexOf(".");
System.out.println(
"the integer part is: " + s.substring(0,t));
System.out.println(
"the decimal part is: " + s.substring(t+1));
}
}保险起见可以先判断是否为浮点数