From 8a106dae7ca06bd87e4fba3063a0def6d6e68835 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Sun, 31 Oct 2021 23:15:01 -0400 Subject: [PATCH 1/7] stillNeedtoFinish --- .../MathUtilities.java | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java index 8076dfe..bdf12c2 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java @@ -11,7 +11,8 @@ public class MathUtilities { * @return sum of `baseValue` and `difference` */ public Integer add(int baseValue, int difference) { - return null; + //adding two value in the parama + return baseValue + difference; } /** @@ -20,7 +21,8 @@ public Integer add(int baseValue, int difference) { * @return sum of `baseValue` and `difference` */ public Long add(long baseValue, long difference) { - return null; + + return baseValue + difference; } /** @@ -29,7 +31,9 @@ public Long add(long baseValue, long difference) { * @return sum of `baseValue` and `difference` */ public Short add(short baseValue, short difference) { - return null; + + return (short)(baseValue + difference); + } /** @@ -38,7 +42,8 @@ public Short add(short baseValue, short difference) { * @return sum of `baseValue` and `difference` */ public Byte add(byte baseValue, byte difference) { - return null; + + return (byte)(baseValue + difference); } /** @@ -47,7 +52,8 @@ public Byte add(byte baseValue, byte difference) { * @return sum of `baseValue` and `difference` */ public Float add(float baseValue, float difference) { - return null; + + return (float)(baseValue + difference); } /** @@ -56,7 +62,8 @@ public Float add(float baseValue, float difference) { * @return sum of `baseValue` and `difference` */ public Double add(double baseValue, double difference) { - return null; + + return (double)(baseValue + difference); } /** @@ -65,7 +72,8 @@ public Double add(double baseValue, double difference) { * @return difference between `baseValue` and `difference` */ public Integer subtract(int baseValue, int difference) { - return null; + + return baseValue - difference; } /** @@ -74,7 +82,8 @@ public Integer subtract(int baseValue, int difference) { * @return difference between `baseValue` and `difference` */ public Long subtract(long baseValue, long difference) { - return null; + + return baseValue - difference; } /** @@ -83,7 +92,7 @@ public Long subtract(long baseValue, long difference) { * @return difference between `baseValue` and `difference` */ public Short subtract(short baseValue, short difference) { - return null; + return (short)(baseValue - difference); } /** @@ -92,7 +101,7 @@ public Short subtract(short baseValue, short difference) { * @return difference between `baseValue` and `difference` */ public Byte subtract(byte baseValue, byte difference) { - return null; + return (byte)(baseValue - difference); } /** @@ -101,7 +110,7 @@ public Byte subtract(byte baseValue, byte difference) { * @return difference between `baseValue` and `difference` */ public Float subtract(float baseValue, float difference) { - return null; + return (float)(baseValue - difference); } /** @@ -110,7 +119,7 @@ public Float subtract(float baseValue, float difference) { * @return difference between `baseValue` and `difference` */ public Double subtract(double baseValue, double difference) { - return null; + return (double)(baseValue - difference); } @@ -120,7 +129,7 @@ public Double subtract(double baseValue, double difference) { * @return division of `dividend` by `divisor */ public Integer divide(int dividend, int divisor) { - return null; + return dividend / divisor; } /** @@ -129,7 +138,7 @@ public Integer divide(int dividend, int divisor) { * @return division of `dividend` by `divisor */ public Long divide(long dividend, long divisor) { - return null; + return dividend / divisor; } /** @@ -138,7 +147,7 @@ public Long divide(long dividend, long divisor) { * @return division of `dividend` by `divisor */ public Short divide(short dividend, short divisor) { - return null; + return (short)(dividend / divisor); } /** @@ -147,7 +156,7 @@ public Short divide(short dividend, short divisor) { * @return division of `dividend` by `divisor */ public Byte divide(byte dividend, byte divisor) { - return null; + return (byte)(dividend / divisor); } /** @@ -156,7 +165,7 @@ public Byte divide(byte dividend, byte divisor) { * @return division of `dividend` by `divisor */ public Float divide(float dividend, float divisor) { - return null; + return (float)(dividend / divisor); } /** @@ -165,7 +174,7 @@ public Float divide(float dividend, float divisor) { * @return division of `dividend` by `divisor */ public Double divide(double dividend, double divisor) { - return null; + return (double)(dividend / divisor); } @@ -175,7 +184,7 @@ public Double divide(double dividend, double divisor) { * @return product of `multiplicand` by `multiplier` */ public Integer multiply(int multiplicand, int multiplier) { - return null; + return multiplicand * multiplier; } /** @@ -184,7 +193,7 @@ public Integer multiply(int multiplicand, int multiplier) { * @return product of `multiplicand` by `multiplier` */ public Long multiply(long multiplicand, long multiplier) { - return null; + return multiplicand * multiplier; } /** @@ -193,7 +202,7 @@ public Long multiply(long multiplicand, long multiplier) { * @return product of `multiplicand` by `multiplier` */ public Short multiply(short multiplicand, short multiplier) { - return null; + return (short)(multiplicand * multiplier); } /** * @param multiplicand value to be multiplied From 471dba24f9fb3933ecd02d8437abbc2add160c59 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Sun, 31 Oct 2021 23:22:35 -0400 Subject: [PATCH 2/7] stillneedtofinsih --- .../danny_do_better_exercises/MathUtilities.java | 6 +++--- .../danny_do_better_exercises/PredicateUtilities.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java index bdf12c2..bf96cbf 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java @@ -210,7 +210,7 @@ public Short multiply(short multiplicand, short multiplier) { * @return product of `multiplicand` by `multiplier` */ public Byte multiply(byte multiplicand, byte multiplier) { - return null; + return (byte)(multiplicand * multiplier); } /** @@ -219,7 +219,7 @@ public Byte multiply(byte multiplicand, byte multiplier) { * @return product of `multiplicand` by `multiplier` */ public Float multiply(float multiplicand, float multiplier) { - return null; + return (float)(multiplicand * multiplier); } /** @@ -228,6 +228,6 @@ public Float multiply(float multiplicand, float multiplier) { * @return product of `multiplicand` by `multiplier` */ public Double multiply(double multiplicand, double multiplier) { - return null; + return (double)(multiplicand * multiplier); } } diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java index cb5f822..12bce7b 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java @@ -10,7 +10,8 @@ public class PredicateUtilities { * @return true if `x` is greater than `y` */ public Boolean isGreaterThan(int x, int y) { - return null; + if (x > y); + return true; } /** From 33ffccc5e33efbf00fd7641a6d332c56fbd07dc2 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 2 Nov 2021 14:02:27 -0400 Subject: [PATCH 3/7] Just Saving it --- .../MathUtilities.java | 18 ++++++++++++- .../PredicateUtilities.java | 13 ++++++---- .../StringUtilities.java | 26 ++++++++++++++----- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java index bf96cbf..5145189 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java @@ -11,7 +11,7 @@ public class MathUtilities { * @return sum of `baseValue` and `difference` */ public Integer add(int baseValue, int difference) { - //adding two value in the parama + //adding two value in the para return baseValue + difference; } @@ -92,6 +92,7 @@ public Long subtract(long baseValue, long difference) { * @return difference between `baseValue` and `difference` */ public Short subtract(short baseValue, short difference) { + return (short)(baseValue - difference); } @@ -101,6 +102,7 @@ public Short subtract(short baseValue, short difference) { * @return difference between `baseValue` and `difference` */ public Byte subtract(byte baseValue, byte difference) { + return (byte)(baseValue - difference); } @@ -110,6 +112,7 @@ public Byte subtract(byte baseValue, byte difference) { * @return difference between `baseValue` and `difference` */ public Float subtract(float baseValue, float difference) { + return (float)(baseValue - difference); } @@ -119,6 +122,7 @@ public Float subtract(float baseValue, float difference) { * @return difference between `baseValue` and `difference` */ public Double subtract(double baseValue, double difference) { + return (double)(baseValue - difference); } @@ -129,6 +133,7 @@ public Double subtract(double baseValue, double difference) { * @return division of `dividend` by `divisor */ public Integer divide(int dividend, int divisor) { + return dividend / divisor; } @@ -138,6 +143,7 @@ public Integer divide(int dividend, int divisor) { * @return division of `dividend` by `divisor */ public Long divide(long dividend, long divisor) { + return dividend / divisor; } @@ -147,6 +153,7 @@ public Long divide(long dividend, long divisor) { * @return division of `dividend` by `divisor */ public Short divide(short dividend, short divisor) { + return (short)(dividend / divisor); } @@ -156,6 +163,7 @@ public Short divide(short dividend, short divisor) { * @return division of `dividend` by `divisor */ public Byte divide(byte dividend, byte divisor) { + return (byte)(dividend / divisor); } @@ -165,6 +173,7 @@ public Byte divide(byte dividend, byte divisor) { * @return division of `dividend` by `divisor */ public Float divide(float dividend, float divisor) { + return (float)(dividend / divisor); } @@ -174,6 +183,7 @@ public Float divide(float dividend, float divisor) { * @return division of `dividend` by `divisor */ public Double divide(double dividend, double divisor) { + return (double)(dividend / divisor); } @@ -184,6 +194,7 @@ public Double divide(double dividend, double divisor) { * @return product of `multiplicand` by `multiplier` */ public Integer multiply(int multiplicand, int multiplier) { + return multiplicand * multiplier; } @@ -193,6 +204,7 @@ public Integer multiply(int multiplicand, int multiplier) { * @return product of `multiplicand` by `multiplier` */ public Long multiply(long multiplicand, long multiplier) { + return multiplicand * multiplier; } @@ -202,6 +214,7 @@ public Long multiply(long multiplicand, long multiplier) { * @return product of `multiplicand` by `multiplier` */ public Short multiply(short multiplicand, short multiplier) { + return (short)(multiplicand * multiplier); } /** @@ -210,6 +223,7 @@ public Short multiply(short multiplicand, short multiplier) { * @return product of `multiplicand` by `multiplier` */ public Byte multiply(byte multiplicand, byte multiplier) { + return (byte)(multiplicand * multiplier); } @@ -219,6 +233,7 @@ public Byte multiply(byte multiplicand, byte multiplier) { * @return product of `multiplicand` by `multiplier` */ public Float multiply(float multiplicand, float multiplier) { + return (float)(multiplicand * multiplier); } @@ -228,6 +243,7 @@ public Float multiply(float multiplicand, float multiplier) { * @return product of `multiplicand` by `multiplier` */ public Double multiply(double multiplicand, double multiplier) { + return (double)(multiplicand * multiplier); } } diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java index 12bce7b..85e6198 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java @@ -20,7 +20,8 @@ public Boolean isGreaterThan(int x, int y) { * @return true if `x` is less than `y` */ public Boolean isLessThan(int x, int y) { - return null; + if (x < y); + return true; } /** @@ -29,7 +30,8 @@ public Boolean isLessThan(int x, int y) { * @return true if `x` is greater than or equal to `y` */ public Boolean isGreaterThanOrEqualTo(int x, int y) { - return null; + if(x >= y); + return true; } /** @@ -38,7 +40,8 @@ public Boolean isGreaterThanOrEqualTo(int x, int y) { * @return true if `x` is less than or equal to `y` */ public Boolean isLessThanOrEqualTo(int x, int y) { - return null; + if(x <= y); + return true; } @@ -46,14 +49,14 @@ public Boolean isLessThanOrEqualTo(int x, int y) { * @return true */ public Boolean returnTrue() { - return null; + return true; } /** * @return false */ public Boolean returnFalse() { - return null; + return false; } } \ No newline at end of file diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java index 2f776a9..30f5679 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java @@ -8,7 +8,9 @@ public class StringUtilities { * @return `Hello World` as a string */ public static String getHelloWorld() { - return null; + String helloWorld = "Hello World"; + + return helloWorld; } /** @@ -17,7 +19,8 @@ public static String getHelloWorld() { * @return the concatenation of two strings, `firstSegment`, and `secondSegment` */ public static String concatenation(String firstSegment, String secondSegment){ - return null; + + return (firstSegment + secondSegment); } /** @@ -26,7 +29,11 @@ public static String concatenation(String firstSegment, String secondSegment){ * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment` */ public static String concatenation(int firstSegment, String secondSegment){ - return null; + //you're combining an int w/ a string = however you'll be returning a string because the method is calling for a string return. + //Therefore you have to convert an int into a string. In order to combine them together. + String stringFirstSegment = Integer.toString(firstSegment); //converting an int into a string - Integer.toString (static method) <- class method, used directy on the class Math.pow(); System.out.println(). + + return concatenation (stringFirstSegment,secondSegment); } /** @@ -34,7 +41,10 @@ public static String concatenation(int firstSegment, String secondSegment){ * @return the first 3 characters of `input` */ public static String getPrefix(String input){ - return null; + //get the first 3 letters of the String input; input = inp; + // + + return (input.substring(0,3)); } /** @@ -42,7 +52,8 @@ public static String getPrefix(String input){ * @return the last 3 characters of `input` */ public static String getSuffix(String input){ - return null; + + return input.substring(2,5); } /** @@ -51,7 +62,10 @@ public static String getSuffix(String input){ * @return the equivalence of two strings, `inputValue` and `comparableValue` */ public static Boolean compareTwoStrings(String inputValue, String comparableValue){ - return null; + //comparing two inputs to see if they are equivelent + //using Boolean (true/false) to compare if they are + + return Equals(inputValue,comparableValue); } /** From e145664d18eb5c6a5b1c77ef781510fea865e1e5 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 2 Nov 2021 16:47:11 -0400 Subject: [PATCH 4/7] almostthere --- .../danny_do_better_exercises/StringUtilities.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java index 30f5679..32bc57f 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java @@ -63,9 +63,9 @@ public static String getSuffix(String input){ */ public static Boolean compareTwoStrings(String inputValue, String comparableValue){ //comparing two inputs to see if they are equivelent - //using Boolean (true/false) to compare if they are + //using Boolean (true/false) to compare if they are the same - return Equals(inputValue,comparableValue); + return inputValue.equals(comparableValue); } /** @@ -81,6 +81,7 @@ public static Character getMiddleCharacter(String inputValue){ * @return the first sequence of characters */ public static String getFirstWord(String spaceDelimitedString){ + return null; } From 138d515ff34473b002b1e2744f119d131d654f5a Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 2 Nov 2021 17:23:23 -0400 Subject: [PATCH 5/7] assignment --- .../danny_do_better_exercises/StringUtilities.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java index 32bc57f..e738183 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java @@ -73,6 +73,7 @@ public static Boolean compareTwoStrings(String inputValue, String comparableValu * @return the middle character of `inputValue` */ public static Character getMiddleCharacter(String inputValue){ + return null; } @@ -90,7 +91,7 @@ public static String getFirstWord(String spaceDelimitedString){ * @return the second word of a string delimited by spaces. */ public static String getSecondWord(String spaceDelimitedString){ - return null; + return ; } /** From 684c92769ded6e590ea7290dbfbbc539b3d2e9e6 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 2 Nov 2021 20:45:28 -0400 Subject: [PATCH 6/7] saved --- .../StringUtilities.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java index e738183..2feafb5 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java @@ -73,8 +73,16 @@ public static Boolean compareTwoStrings(String inputValue, String comparableValu * @return the middle character of `inputValue` */ public static Character getMiddleCharacter(String inputValue){ - - return null; + //first convert the string into an int + //take the new string = integer, and divide it by two + + int getMiddleCharacter = inputValue.length(); + //convert the string inputValue into an integer; rename main method with new method String + int middleChar = (getMiddleCharacter/2)-1; + //giving (type) int a (variable)middleChar = (variable)getMiddleCharacter divided by 2 (dividing the total letters by 2; minus 1 because the total string was even. + char c = inputValue.charAt(middleChar); + //char c = method to extract the middle char = inputValue (original).charAt(method)(new variable middleChar); + return c; } /** @@ -82,6 +90,9 @@ public static Character getMiddleCharacter(String inputValue){ * @return the first sequence of characters */ public static String getFirstWord(String spaceDelimitedString){ + //first convert the string into an int + //take the new string = integer, and divide it by two + return null; } @@ -91,7 +102,7 @@ public static String getFirstWord(String spaceDelimitedString){ * @return the second word of a string delimited by spaces. */ public static String getSecondWord(String spaceDelimitedString){ - return ; + return null; } /** From 250e00224034706902fc79ebd422f4b524556330 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 2 Nov 2021 23:38:38 -0400 Subject: [PATCH 7/7] reviewlab --- .../PredicateUtilities.java | 25 ++++++++-- .../StringUtilities.java | 46 ++++++++++++------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java index 85e6198..831c4d1 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java @@ -10,8 +10,12 @@ public class PredicateUtilities { * @return true if `x` is greater than `y` */ public Boolean isGreaterThan(int x, int y) { - if (x > y); + if (x > y) return true; + + else{ + return false; + } } /** @@ -20,8 +24,12 @@ public Boolean isGreaterThan(int x, int y) { * @return true if `x` is less than `y` */ public Boolean isLessThan(int x, int y) { - if (x < y); + if (x < y) return true; + + else{ + return false; + } } /** @@ -30,8 +38,12 @@ public Boolean isLessThan(int x, int y) { * @return true if `x` is greater than or equal to `y` */ public Boolean isGreaterThanOrEqualTo(int x, int y) { - if(x >= y); + if(x >= y) return true; + + else{ + return false; + } } /** @@ -40,8 +52,12 @@ public Boolean isGreaterThanOrEqualTo(int x, int y) { * @return true if `x` is less than or equal to `y` */ public Boolean isLessThanOrEqualTo(int x, int y) { - if(x <= y); + if(x <= y) return true; + //return (x<=y); java will just return it true or false + else{ + return false; + } } @@ -56,6 +72,7 @@ public Boolean returnTrue() { * @return false */ public Boolean returnFalse() { + return false; } diff --git a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java index 2feafb5..71ffb90 100644 --- a/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java +++ b/src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java @@ -72,29 +72,28 @@ public static Boolean compareTwoStrings(String inputValue, String comparableValu * @param inputValue the value input from user * @return the middle character of `inputValue` */ - public static Character getMiddleCharacter(String inputValue){ - //first convert the string into an int - //take the new string = integer, and divide it by two - - int getMiddleCharacter = inputValue.length(); - //convert the string inputValue into an integer; rename main method with new method String - int middleChar = (getMiddleCharacter/2)-1; - //giving (type) int a (variable)middleChar = (variable)getMiddleCharacter divided by 2 (dividing the total letters by 2; minus 1 because the total string was even. - char c = inputValue.charAt(middleChar); - //char c = method to extract the middle char = inputValue (original).charAt(method)(new variable middleChar); - return c; + public static Character getMiddleCharacter(String inputValue){ //<-- method signature + + //.length is a property of String; and String is a non-primitive type or a class (because of the uppercase); .length + int middleIndex = (inputValue.length()-1)/2; + //-1 because the starting index is 0; it would that the total index length of inputValue minus by 1 position, divided by 2 + char ch = inputValue.charAt(middleIndex); + //type variable is taking the inputValue.charAt(string method) returning the value of the middleIndex position of the letter that was in the string. + return ch; } + /** * @param spaceDelimitedString a string, representative of a sentence, containing spaces * @return the first sequence of characters */ public static String getFirstWord(String spaceDelimitedString){ - //first convert the string into an int - //take the new string = integer, and divide it by two - + //represents a sentence = example - the brown fox (w/ spaces) + //return the first sequence of characters - return "the" + //take the String input and make it into an array w/ a delimiter (specified in parathesis)that will remove the spaces. Then take the index position 0 (which represents the first word.) + String noSpace[] = spaceDelimitedString.split(" "); //.split is a string method that allows you to specify what in the string you want to removes it. - return null; + return noSpace[0]; } /** @@ -102,7 +101,10 @@ public static String getFirstWord(String spaceDelimitedString){ * @return the second word of a string delimited by spaces. */ public static String getSecondWord(String spaceDelimitedString){ - return null; + //we are going to take the input and change it into an array, we will remove the spaces, and get the position 1 of the array. + String noSpace[] = spaceDelimitedString.split(" "); + + return noSpace[1]; } /** @@ -110,6 +112,16 @@ public static String getSecondWord(String spaceDelimitedString){ * @return an identical string with characters in reverse order. */ public static String reverse(String stringToReverse){ - return null; + //to change the input, into a character array and then reverse the indices + //.toCharArray - representation of the each individual characters of the string, including spaces, and punctuation marks. + char inputCharArray[] = stringToReverse.toCharArray(); // turning a string input into a char array + //when returning a string length = total number of string (i.e. ford = 4 length) vs. indexes you will be returning the total position based on zero (i.e. ford = indices (0(f), 1(o), 2(r), 3(d)) + String results = ""; + for(int i = inputCharArray.length-1; i >= 0; i--){ + results = results + inputCharArray[i]; //containing the results of the for(loop) into the declared variable above is the same as results = results(not literal) (track previous number of the index) plus the for(loop) + } + //the for(loop) sets the condition for the charArray input, into the lenght(totalstring not indices) to start the count at the last index and continue to count backwards until its equal to zero. + //i.e. FORD = 0123 start count at 3, 2, 1 , 0 + return results; } }