|
| 1 | +public class MathUtil |
| 2 | +{ |
| 3 | + public static void main(String[] args) |
| 4 | + { |
| 5 | + int total = getTotal(1, 2); |
| 6 | + |
| 7 | + System.out.println(total); |
| 8 | + double cargoVolume = getCargoVolume(2, 2, 2, false); |
| 9 | + System.out.println(cargoVolume); |
| 10 | + |
| 11 | + int absoluteAnswer = absoluteSum(-5, 2); |
| 12 | + System.out.println(absoluteAnswer); |
| 13 | + |
| 14 | + int absoluteAnswerTwo = absoluteSum(-5, 2, -3); |
| 15 | + System.out.println(absoluteAnswerTwo); |
| 16 | + |
| 17 | + } |
| 18 | + |
| 19 | + public static int getTotal(int firstNumber, int secondNumber) |
| 20 | + { |
| 21 | + int sum = firstNumber + secondNumber; |
| 22 | + |
| 23 | + return sum; |
| 24 | + } |
| 25 | + |
| 26 | + public static double getCargoVolume(double height, double length, double depth, boolean heavyDuty) |
| 27 | + { |
| 28 | + |
| 29 | + double materialThickness = .25; |
| 30 | + if (heavyDuty) ; |
| 31 | + materialThickness = .25 * 2; |
| 32 | + double interiorHeight = height - (2 * materialThickness); |
| 33 | + double interiorLength = length - (2 * materialThickness); |
| 34 | + double interiorDepth = depth - (2 * materialThickness); |
| 35 | + double cargoVolume = interiorHeight * interiorLength * interiorDepth; |
| 36 | + return cargoVolume; |
| 37 | + } |
| 38 | + |
| 39 | + public static int absoluteSum(int numberone, int numberTwo) |
| 40 | + { |
| 41 | + int absoluteOne = Math.abs(numberone); |
| 42 | + int absoluteTwo = Math.abs(numberTwo); |
| 43 | + int absoluteAnswer = absoluteOne + absoluteTwo; |
| 44 | + return absoluteAnswer; |
| 45 | + } |
| 46 | + |
| 47 | + public static int absoluteSum(int numberone, int numberTwo, int numberThree) |
| 48 | + { |
| 49 | + int absoluteOne = Math.abs(numberone); |
| 50 | + int absoluteTwo = Math.abs(numberTwo); |
| 51 | + int absoluteThree = Math.abs(numberThree); |
| 52 | + int absoluteAnswerTwo = absoluteOne + absoluteTwo + absoluteThree; |
| 53 | + return absoluteAnswerTwo; |
| 54 | + } |
| 55 | +} |
0 commit comments