diff --git a/src/Practice.java b/src/Practice.java index 89acfd9..596cd83 100644 --- a/src/Practice.java +++ b/src/Practice.java @@ -18,6 +18,10 @@ public class Practice { */ public static void printItems(String[] items) { // TODO: Implement this method here! + //use for loop to loop through every single item and print out + for (int i = 0; i < items.length; i++){ + System.out.println(items[i]); + } } /** @@ -45,7 +49,14 @@ public static void printItems(String[] items) { */ public static boolean moreThanDouble(int a, int b) { // TODO: Delete the dummy return statement and implement this method here! - return false; + //use if statement to check if a values twice of b and return true + + if (a > b*2){ + return true; + } else { + return false; + } + } @@ -71,8 +82,23 @@ public static boolean moreThanDouble(int a, int b) { */ public static boolean allStartWithA(String[] words) { // TODO: Delete the dummy return statement and implement this method here! - return false; + + //return true if array is empty, or + if (words == null || words.length == 0){ + return true; + } + + //use for loop to loop through every word to check if the word starts with A whether if it's A or a + for (String word : words){ + + if (!word.toUpperCase().startsWith("A")){ + return false; + } + } + return true; + } + public static void main(String[] args) { System.out.println();