Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions src/Practice.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class Practice {
*/
public static void printItems(String[] items) {
// TODO: Implement this method here!
for(int i = 0; i < items.length; i++) {
System.out.println(items[i]);
System.out.println("just a test");
}
}

/**
Expand Down Expand Up @@ -45,54 +49,51 @@ 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;
int doubleValue = b * 2;
if (a > doubleValue) {
return true;
}
return false;
}


/**
* Returns whether every word in the array starts with the letter A (either
* upper or lower case).
*
* Examples:
* input:
* {"alligators", "are", "AWESOME"}
* return:
* true
*
* input:
* {"apes", "can", "be", "amazing"}
* return:
* false
*
* Edge case: If array is empty, return true.
*

/*
* @param words a array of words
* @return true if every word starts with A (case-insensitive), false otherwise.
*/
public static boolean allStartWithA(String[] words) {
// TODO: Delete the dummy return statement and implement this method here!
return false;
}
if(words.length == 0){
return true;
}
for(int i = 0; i < words.length; i++) {
char lowerCase = Character.toLowerCase(words[i].charAt(0));
if(lowerCase != 'a') {
return false;
}
}
return true;
}


public static void main(String[] args) {
System.out.println();
System.out.println("///// Print items /////");
System.out.println("Calling printItems(new String[]{\"welcome\", \"to\", \"sdev\", \"220\"})");
printItems(new String[]{"welcome", "to", "sdev", "220"});
printItems(new String[]{"stephn curry", "to", "Lebron", "James"});
System.out.println();
System.out.println("Calling printItems(new String[]{\"hello\", \"world\"})");
printItems(new String[]{"hello", "world"});

System.out.println();
System.out.println("///// More than Double /////");
System.out.println("moreThanDouble(10, 3): " + moreThanDouble(10, 3));
System.out.println("moreThanDouble(10, 3): " + moreThanDouble(90, 3));
System.out.println("moreThanDouble(6, 4): " + moreThanDouble(6, 4));
System.out.println("moreThanDouble(4, 2): " + moreThanDouble(4, 2));

System.out.println();
System.out.println("///// All Start With A /////");
System.out.println("allStartWithA(new String[]{\"alligators\", \"are\", \"AWESOME\"}): " + allStartWithA(new String[]{"alligators", "are", "AWESOME"}));
System.out.println("allStartWithA(new String[]{\"apes\", \"can\", \"be\", \"amazing\"}): " + allStartWithA(new String[]{"apes", "can", "be", "amazing"}));
System.out.println("allStartWithA(new String[]{\"alligators\", \"are\", \"AWESOME\"}): " + allStartWithA(new String[]{"sdev220", "is", "NOT AWESOME"}));
System.out.println("allStartWithA(new String[]{\"apes\", \"can\", \"be\", \"amazing\"}): " + allStartWithA(new String[]{"stephen curry", "Lebron James", "be", "amazing"}));
System.out.println("allStartWithA(new String[]{}): " + allStartWithA(new String[]{}));
System.out.println();
}
Expand Down