在 java 中需要帮助从 DataInputStream 获取输入

Need Help in taking Input from DataInputStream in java

这是我的代码:

import java.io.*;

class InterestCalcs {

    public static void main(String arg[]) {
        Float prinAmount = new Float(0);
        Float ROI = new Float(0);
        DataInputStream in = new DataInputStream(System.in);
        String tempString;
        int noOfYears;
        System.out.println("Enter Amount :");
        System.out.flush();
        tempString = in .readLine();
        prinAmount = Float.valueOf(tempString);
        System.out.println("Enter ROI:");
        System.out.flush();
        tempString = in .readLine();
        ROI = Float.valueOf(tempString);
        System.out.flush();
        tempString = in .readLine();
        noOfYears = Integer.parseInt(tempString);
        float interestTotal = ROIprinAmountnoOfYears;
        System.out.println("The total interest is " + interestTotal);
    }
}

尝试使用 BufferedReader

BufferedReader reader = 新 BufferedReader(新 InputStreamReader(System.in));

tempString = reader.readLine();