I'm building a program and we are specifically not allowed to use multiple returns within a submodule.
I was wondering how to pass jimArea, ashtynArea and steveArea from the submodule areaCalc so that they can be used in main. Here is the submodule I'm referring to, followed by the full code.
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);
}
Here is the full code. Originally I had it just returning area, but it turns out I needed 3 areas, so I'm not sure how to do that without doing multiple returns.
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 Width of Steve's Pool in Metres.");
double steveWidth = sc.nextDouble();
System.out.println("Please enter the Length of Steve's Pool in Metres.");
double steveLength = sc.nextDouble();
System.out.println("Please enter the Depth of Jim's Pool in Metres.");
double jimDepth = sc.nextDouble()
System.out.println("Please enter the Width of Jim's Pool in Metres.");
double jimWidth = sc.nextDouble();
System.out.println("Please enter the Length of Jim's Pool in Metres.");
double jimLength = sc.nextDouble;
System.out.println("Please enter the Depth of Ashtyn's Pool in Metres.");
double ashtynDepth = sc.nextDouble();
System.out.println("Please enter the Width of Ashtyn's Pool in Metres.");
double ashtynWidth = sc.nextDouble();
Systemm.out.println("Please enter the Length of Ashtyn's Pool in Metres.");
double ashtynLength = sc.nextDouble();
int area = areaCalc(steveDepth,steveWidth,steveLength,jimDepth,jimWidth,jimLength,ashtynDepth,ashtynLength,ashtynWidth);
int numRays = rayCalc(steveArea);
int numSharks = sharkCalc(jimArea);
int numTurtles = turtleCalc(ashtynArea);
System.out.println("Steve can store " + numRays + " Sting Rays in his " + steveArea + " Metres Cubed Pool.");
System.out.println("Jim can store " + numSharks + " Sharks in his " + jimArea + " Metres Cubed Pool.");
System.out.println("Ashtyn can store " + numTurtles + " Turtles in her " + ashtynArea + " Metres Cubed Pool.");
}
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);
return area;
}
public static int rayCalc(int steveArea)
{
int numRays = (int)(steveArea * 0.5);
return numRays;
}
public static int sharkCalc(int jimArea)
{
int numSharks = (int)(jimArea * 0.1);
return numSharks;
}
public static int turtleCalc(int ashtynArea)
{
int numTurtles = (int)(ashtynArea * 1.2);
return numTurtles;
}
}
Any help is greatly appreciated, thanks. John