Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从另一个不将输入作为其签名一部分的方法调用一个方法(Java)_Java_Parameter Passing - Fatal编程技术网

从另一个不将输入作为其签名一部分的方法调用一个方法(Java)

从另一个不将输入作为其签名一部分的方法调用一个方法(Java),java,parameter-passing,Java,Parameter Passing,我有一个返回存款金额的方法 public double take_deposit_amount_into_checking_account() throws InputMismatchException { System.out.println("Enter the amount to be depsosited in the format XX:YY"); Scanner sc = new Scanner(System.in); double deposit_amoun

我有一个返回存款金额的方法

public double take_deposit_amount_into_checking_account() throws InputMismatchException {
    System.out.println("Enter the amount to be depsosited in the format XX:YY");
    Scanner sc = new Scanner(System.in);
    double deposit_amount = sc.nextDouble();
    System.out.println("You have deposited " + deposit_amount + " into your checkings account ");
    user_option(); // call user option
    return deposit_amount;

}
我有一个secound方法(见下文),它不将输入作为其签名的一部分,但会利用上面的take_deposit_amount_into_checking_account()中的返回值

在执行初始化beleow之后

双倍存款金额=将存款金额存入支票账户()

我仍然无法成功地将存款金额的实际值传递到从支票()的双重取款中


我不知道如何在第二个方法中使用我的第一个方法的返回值。

我不知道你到底想做什么,但下面是我的初步发现

把存款金额存入支票账户应该在某处打电话 应使用方法从检查中提取。所以你应该换个颜色

double depositAmount = deposit_amount;


您在哪里从取款检查方法中调用了take\u deposit\u amount\u into\u checking\u account方法?提示:
take\u deposit\u amount\u into\u checking\u account()
并没有真正将任何金额计入任何帐户:它只是请求用户输入金额并返回。那之后钱都到哪里去了?“支票账户”在哪里?
drawing\u-from\u-checking()
应该从中提取?感谢您的提示,我存储了用户输入的双倍存款金额=sc.nextDouble();将转换为变量(double deposit\u amount\u from\u user),然后在我的逻辑中使用该变量,该变量的行为仍然与方法的行为完全相同//take deposit$from user public double take\u deposit\u amount\u into\u checking\u account()抛出。。。扫描仪sc=新的扫描仪(System.in);双倍存款金额=sc.nextDouble();来自用户的双倍存款金额=存款金额;初始化双倍存款金额=将存款金额记入支票账户();inside Drawl_from_checking()未按我的要求分配返回值deposit_amount。相反,它的作用是调用take\u deposit\u amount\u进入\u checking\u account()。也就是说,它提示“amoun to deposit”,而不是将存款金额的值指定为双倍存款金额。
double depositAmount = deposit_amount;
double depositAmount = take_deposit_amount_into_checking_account();