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
35 changes: 27 additions & 8 deletions src/Practice.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ public class Practice {
*
* @param items an array of strings to print
*/
public static void printItems(String[] items) {
// TODO: Implement this method here!
public static void printItems(String[] items)
{
for (String x : items)
{
System.out.println(x);
}
}

/**
Expand All @@ -43,9 +47,12 @@ public static void printItems(String[] items) {
* @param b an int
* @return true if a is strictly more than twice the value of b, false otherwise
*/
public static boolean moreThanDouble(int a, int b) {
// TODO: Delete the dummy return statement and implement this method here!
return false;
public static boolean moreThanDouble(int a, int b)
{
if (a > b * 2) // if b * 2 is less than a, return true!
return true;
else
return false;
}


Expand All @@ -69,9 +76,21 @@ public static boolean moreThanDouble(int a, int b) {
* @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;
public static boolean allStartWithA(String[] words)
{
for (String x : words)
{
String currentWord = x.toLowerCase();

for (int i = 0; i < currentWord.length(); i++)
{
if (currentWord.charAt(0) != 'a')
{
return false;
}
Comment on lines +87 to +90
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if we had a capital A?

}
}
return true;
}

public static void main(String[] args) {
Expand Down