我目前正在编写一个程序,它将读取指定的文本文件,该文件检查每个买入/卖出/摘要的交易值,并检查算术,如果买卖报表中的交易不等于总交易量.在摘要中给出它然后输出错误并关闭程序.但是目前我的方法scanMoneyValue有一个错误,它说它没有返回一个double,实际上它是.我应该采用不同的方式从我的方法中返回值吗?这是我的代码供参考:
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class RecurrsionFileChecker {
public static void main(String[] args) {
int result;
//File Chooser Window
JFileChooser chooser = new JFileChooser("/home/nick/workspace/CS 1410-001/src/assignment03");
chooser.setDialogTitle("Please choose a file to be checked");
result = chooser.showOpenDialog(null);
//User Cancelled the chooser
if (result == JFileChooser.CANCEL_OPTION)
return;
File inputfile = chooser.getSelectedFile();
try
{
Scanner in = new Scanner(inputfile);
//Call Method to look at next transaction
scanNextTransaction(in);
}
catch (IOException e)
{
System.out.println("Could not read …Run Code Online (Sandbox Code Playgroud)