diff --git a/CS207-2-HW4.pdf b/CS207-2-HW4.pdf new file mode 100644 index 0000000..02e6a5e Binary files /dev/null and b/CS207-2-HW4.pdf differ diff --git a/TestLargeDecimals.java b/TestLargeDecimals.java new file mode 100644 index 0000000..863ec2c --- /dev/null +++ b/TestLargeDecimals.java @@ -0,0 +1,40 @@ +/* + * NEIU CS207-2 Fall 2018 + * Homework 4 TestLargeDecimals.java + * This is the class with a main(), to test LargeDecimals + */ +import java.math.BigDecimal; +public class TestLargeDecimals +{ + public static void main( String[] args ) + { + LargeDecimals decimals = new LargeDecimals(); + BigDecimal maxOfMins; + + // First 2D test array of type BigDecimal + BigDecimal[][] numbers1 = { + { new BigDecimal("50.0"), new BigDecimal("20.0"), new BigDecimal("80.0"), new BigDecimal("90.0"), new BigDecimal("100.0") }, + { new BigDecimal("77.0"), new BigDecimal("555.0"), new BigDecimal("33.0"), new BigDecimal("44.0"), new BigDecimal("66.0") }, + { new BigDecimal("888.0"), new BigDecimal("15.0"), new BigDecimal("302.0"), new BigDecimal("90.0"), new BigDecimal("123.0") }, + { new BigDecimal("31.0"), new BigDecimal("29.0"), new BigDecimal("30.0"), new BigDecimal("32.0"), new BigDecimal("28.0") } + }; + + // Call the maxOfMin() behavior passing it the 2D array + maxOfMins = decimals.maxOfMins( numbers1 ); + + System.out.println( "The max of the mins in numbers1 is: " + maxOfMins ); + + // Second 2D test array of type BigDecimal + BigDecimal[][] numbers2 = { + { new BigDecimal("-96.0"), new BigDecimal("-41.0"), new BigDecimal("-78.0"), new BigDecimal("12.0"), new BigDecimal("8.0") }, + { new BigDecimal("0.0"), new BigDecimal("-1.0"), new BigDecimal("18.0"), new BigDecimal("-12.0"), new BigDecimal("-48.0") }, + { new BigDecimal("-0.8"), new BigDecimal("1.0"), new BigDecimal("-84.0"), new BigDecimal("-16.0"), new BigDecimal("3.0") }, + { new BigDecimal("6.0"), new BigDecimal("14.0"), new BigDecimal("-14.0"), new BigDecimal("-8.0"), new BigDecimal("-3.0") } + }; + + maxOfMins = decimals.maxOfMins( numbers2 ); + System.out.println( "The max of the mins in numbers2 is: " + maxOfMins ); + + } // End main() + +} // End class TestLargeDecimals diff --git a/TestLargeIntegers.java b/TestLargeIntegers.java new file mode 100644 index 0000000..37450b4 --- /dev/null +++ b/TestLargeIntegers.java @@ -0,0 +1,57 @@ +/* + * NEIU CS207-2 Fall 2018 + * Homework 4 TestLargeIntegers.java + * This is the class with a main(), to test LargeIntegers + */ +import java.math.BigInteger; +public class TestLargeIntegers +{ + public static void main( String[] args ) + { + LargeIntegers numbers = new LargeIntegers(); + + // First test case + BigInteger a = new BigInteger("13"); + BigInteger b = new BigInteger("42"); + BigInteger c = new BigInteger("101"); + + numbers.oneOfThree( a, b, c ); + + // Second test case + BigInteger d = new BigInteger("13"); + BigInteger e = new BigInteger("7"); + BigInteger f = new BigInteger("5"); + + numbers.oneOfThree( d, e, f ); + + // Third test case + BigInteger g = new BigInteger("50"); + BigInteger h = new BigInteger("70"); + BigInteger i = new BigInteger("6"); + + numbers.oneOfThree( g, h, i ); + + // Fourth test case + BigInteger j = new BigInteger("1000"); + BigInteger k = new BigInteger("600"); + BigInteger l = new BigInteger("88"); + + numbers.oneOfThree( j, k, l); + + // Fifth test case + BigInteger m = new BigInteger("10"); + BigInteger n = new BigInteger("10"); + BigInteger o = new BigInteger("9"); + + numbers.oneOfThree( m, n, o ); + + // Sixth test case + BigInteger p = new BigInteger("5"); + BigInteger q = new BigInteger("5"); + BigInteger r = new BigInteger("10"); + + numbers.oneOfThree( p, q, r ); + + } // End main() + +} // End class TestLargeIntegers \ No newline at end of file diff --git a/TestStringPractice.java b/TestStringPractice.java new file mode 100644 index 0000000..a15f134 --- /dev/null +++ b/TestStringPractice.java @@ -0,0 +1,59 @@ +/* + * NEIU CS207-2 Fall 2018 + * Homework 4 TestStringPractice.java + * This is the class with a main(), to test StringPractice + */ +public class TestStringPractice +{ + public static void main(String[] args) + { + StringPractice s1 = new StringPractice("Hello world, welcome to the Java world."); + + /* + System.out.println(s1.makeSubstring(0)); + System.out.println(s1.makeSubstring(6)); + System.out.println(s1.makeSubstring(6, 14)); + System.out.println(s1.makeSubstring(13)); + System.out.println(s1.makeSubstring(0, 12)); + System.out.println(); + */ + + /* + System.out.println(s1.findIndexOf('w')); + System.out.println(s1.findIndexOf('m')); + System.out.println(s1.findIndexOf('x')); + System.out.println(s1.findIndexOf('J')); + System.out.println(s1.findIndexOf('a')); + System.out.println(); + */ + + /* + System.out.println(s1.findIndexOf('w', 7)); + System.out.println(s1.findIndexOf('m', 20)); + System.out.println(s1.findIndexOf('x', 10)); + System.out.println(s1.findIndexOf('J', 30)); + System.out.println(s1.findIndexOf('a', 30)); + System.out.println(); + */ + + /* + System.out.println(s1.findIndexOf("wo")); + System.out.println(s1.findIndexOf("we")); + System.out.println(s1.findIndexOf("He")); + System.out.println(s1.findIndexOf("Ja")); + System.out.println(s1.findIndexOf("va")); + System.out.println(); + */ + + /* + System.out.println(s1.findIndexOf("wo", 7)); + System.out.println(s1.findIndexOf("we", 20)); + System.out.println(s1.findIndexOf("He", 10)); + System.out.println(s1.findIndexOf("Ja", 30)); + System.out.println(s1.findIndexOf("va", 25)); + System.out.println(); + */ + + } // End main() + +} // End class TestStringPractice \ No newline at end of file