Java从键盘输入数字,然后将其转换成数值型数据
package com;
import java.io.*;
public class app3_4 {
public static void main(String [] args) throws IOException
{
float num;
String str;
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入一个实数:");
str=buf.readLine();
num=Float.parseFloat(str);
System.out.println("您输入的数为:"+num);
}
}