Created
April 14, 2019 13:42
-
-
Save PokerFacem8/d9471eb748997a505a540c11678a0a63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class challenge337 { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Choose the X,Y,x,y values seperated by ','."); | |
String[] numbers = new String[4]; | |
numbers = sc.nextLine().split(","); | |
System.out.println("Choose 1-fit1, 2-fit2, 3-fit3"); | |
int option = sc.nextInt(); | |
switch (option) { | |
case 1: | |
System.out.println("Result: " + fit1(numbers)); | |
break; | |
case 2: | |
System.out.println("Result: " + fit2(numbers)); | |
break; | |
case 3: | |
System.out.println("Result: " + fit3(numbers)); | |
break; | |
default: | |
main(args); | |
} | |
} | |
public static int fit1(String[] numbers) { | |
//X/x | |
int xValue = (int) Math.floor(Double.valueOf(numbers[0]) / Double.valueOf(numbers[2])); | |
//Y/y | |
int yValue = (int) Math.floor(Double.valueOf(numbers[1]) / Double.valueOf(numbers[3])); | |
return xValue * yValue; | |
} | |
public static int fit2(String[] numbers) { | |
//X/y | |
int xValue = (int) Math.floor(Double.valueOf(numbers[0]) / Double.valueOf(numbers[3])); | |
//Y/x | |
int yValue = (int) Math.floor(Double.valueOf(numbers[1]) / Double.valueOf(numbers[2])); | |
return Math.max(fit1(numbers), xValue * yValue); | |
} | |
public static int fit3(String[] numbers) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Choose de Z and z values seperated by ','."); | |
String[] zAxis = new String[2]; | |
zAxis = sc.nextLine().split(","); | |
//X/x | |
int xValue = (int) Math.floor(Double.valueOf(numbers[0]) / Double.valueOf(numbers[2])); | |
//Y/y | |
int yValue = (int) Math.floor(Double.valueOf(numbers[1]) / Double.valueOf(numbers[3])); | |
//Z/z | |
int zValue = (int) Math.floor(Double.valueOf(zAxis[0]) / Double.valueOf(zAxis[1])); | |
int normal = xValue * yValue * zValue; | |
//X/y | |
int xRValue = (int) Math.floor(Double.valueOf(numbers[0]) / Double.valueOf(numbers[3])); | |
//Y/x | |
int yRValue = (int) Math.floor(Double.valueOf(numbers[1]) / Double.valueOf(numbers[2])); | |
int rotation = xRValue * yRValue * zValue; | |
return Math.max(normal, rotation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment