小编Joh*_*ohn的帖子

如何在不使用多个返回的情况下返回值

我正在构建一个程序,我们特别不允许在子模块中使用多个返回.

我想知道如何通过jimArea,ashtynAreasteveArea从子模块,areaCalc以便他们可以在主要使用.这是我所指的子模块,后面是完整的代码.

public static int areaCalc(double depth, double width, double length)
{
 int jimArea = (int)(jimDepth * jimWidth * jimLength);
 int steveArea = (int)(steveDepth * steveWidth * steveLength);
 int ashtynArea = (int)(ashtynDepth * ashtynWidth * ashtynLength);
}
Run Code Online (Sandbox Code Playgroud)

这是完整的代码.最初我只是回到了区域,但事实证明我需要3个区域,所以我不知道如何在不做多次返回的情况下做到这一点.

import java.util.*;
public class PoolStorageCalculation
{
public static void main(String [] args)
{
 Scanner sc = new Scanner(System.in);
 System.out.println("Please enter the Depth of Steve's Pool in Metres.");
 double steveDepth = sc.nextDouble();
 System.out.println("Please enter the …
Run Code Online (Sandbox Code Playgroud)

java return

2
推荐指数
1
解决办法
79
查看次数

标签 统计

java ×1

return ×1