Conditionals/Basics
Methods
Strings
Loops
Arrays
100

What type of variable/result can contain the values true or false?

Booleans

100

What is a method?

A block of code that, when called, will preform all code inside of it

100

What is a char/Character?

A single character or symbol, separate of type string and surrounded by single quotations

100

What is a while loop?

This loop is indefinite, and will continue to repeat unless a condition is met

100

Create a new array with a length of 5

int arr [] = new int [5];

200

This code is used to check if a statement or expression is true or false

What is an if statement?

200

Label the parts of this method

public static int Review (int x, int y){

}

Access modifiers: public static

Return type: int

Method name: Review

Parameter(s): x, y

200

This method extracts and returns a part of a string from a start and end value.

What is a substring?

200

This loop is definite, and requires a starting value, an end value, and how many times the value should increase 

What is a for loop?

200

What is an array?

A collection of data of a similar type; its individual values can vary

300

Create a block of code that checks if two integers input are either 6, or if their sum is a multiple of 6

Use this method to start your code:

public static boolean six (int a, int b){

}

  if (a==6 || b==6){

    return true;

  }else if ( (a+b) % 6 == 0 ){

    return true;

  }

  return false;

}


300

Create a method that will return the minimum of three numbers

public static int minimunNum (int a, int b, int c){

return Math.min(Math.min(a, b), c);

}

300

What does this code print

String str = "Coding";

System.out.print(str.charAt(5));


'n'

300

Create code that will print a line of symbols, entered by the user, an amount of times, also entered by the user

  System.out.println("Number of Symbols: ");

    Integer x = Integer.parseInt(scan.nextLine());

    System.out.println("Enter Symbol");

    String y = scan.nextLine();

    

    for (int i = 0; i <x; i++ ){

      System.out.print(y + " ");

}

300

How do you iterate through an array?



Using a for loop


400

Create code that will convert the integer 5364, in seconds, into hours and minutes and seconds.


1 hr, 29 mins, 24 second

int h = left/3600;

    left = left%3600;

    int m = left/60;

    left = left % 60;

    int seconds = left/1;

    left = left % 1;

System.out.println("Hours: " + h);

  System.out.println("Minutes: " + m);    

  System.out.println("Seconds: " + seconds);  

400

Create this pattern:

1

12

123

1234

12345

1234

123

12

1

public static void pattern(int x){

    for (int i = 1; i <x; i++){

      System.out.println(" ");

      for (int n = 1; n <= i; n++){

        System.out.print(n);

      }

    }

    for (int i = x; i > 0; i--){

      System.out.println(" ");

      for (int n = 1; n <= i; n++){

        System.out.print(n);

      }

    }

  }

400

What does this code do?

BONUS: What is the value of count when str is "racecar"?

public static int unknown2 (String str){

    int count = 0;

for (int i = 0; i < str.length(); i++){

         if (str.charAt(i) == 'c'){

        count++;

}

}

return count;

}

Returns how many times the character "c" appears in a string

400

Trace this code (BONUS: What does this code do?) :

for (int x = 1; x <= 15; x++) {

      if (x%3 ==0){

        System.out.print(x +" "+ x+ " ");

      } else if (x%2 != 0){

        System.out.print(x+" "); 

      } 

    }

1 3 3 5 6 6 7 9 9 11 12 12 13 15 15

Bonus: Prints every odd number from 1-15, with the exception that if the number is a multiple of three then print the number twice

400

Trace this array when arr is {1, 8, 3, 4, 8, 8, 1}, what does the method return?:

public static int unknown3(int[] arr){

    int count = 0;

      for (int i =0; i<arr.length-1; ++i){

        if (arr[i] == 8 && arr[i+1] == 8){

          count = count + 2;

        }

        if (arr[i] == 8){

          count++;

        }

      }

    return count;

  }

This method returns 4

500

Trace this code when "a" is 13

BONUS: What does this code do?

 public static boolean unknown (int a){

    for (int i = 2; i < a; i++){

            if (a%i == 0){

                return false;

        }

    }

    return true;

}

Returns true

BONUS: Returns true if the number is a prime number

500

Create a method that will find the greatest common factor of two numbers


 public static int gcf (int x, int y){

    int gcFactor = 0;

    int max = (Math.max(x, y));

    for (int i = 1; i < max ; i++){

      if (x % i == 0 && y % i == 0){

        gcFactor = i;

      }

    }

    return (gcFactor);

  }

500

Create a block of code that wil mix two strings together flipping between each strings characters

ex: ("Hello", "Bye")

Output: (HBeylelo)

Use this method to start your code:

public static String mixString(String a, String b) {

public static String mixString(String a, String b) { 

String ans = "";

  if (a.length()>=b.length()){

    for (int i = 0; i < b.length(); i++){

      ans = ans + a.charAt(i);

      ans = ans+b.charAt(i);

    }

    ans = ans + a.substring(b.length());

  }else if (b.length()>=a.length()){

    for (int i = 0; i < a.length(); i++){

      ans = ans + a.charAt(i); 

      ans = ans+b.charAt(i);

    }

    ans= ans + b.substring(a.length());

  }

  return ans;

}

500

Create a block of code that will determine if a number is abundant or deficient

(A number is deficient if the sum of its divisors is less than the number (1 AND THE NUMBER EXCLUSIVE))

 int factor = 0;

    int sum = 0;

    System.out.println("ENTER A NUM");

    Integer x = Integer.parseInt(scan.nextLine());

    for (int i = 1; i < x; i++){

      if (x%i == 0){

        sum = i+sum;

        factor = factor+1;

      }

    }

    if (sum>x){

      System.out.println("Abundant");

    }else{

      System.out.println("Deficient");

  }

500

Create code that will take an array and return the max, min, and average of all elements

Use this method to start your code

public static void checkArray(int[] arr){

public static void checkArray(int[] arr){

    double count = 0;

    double average = 0;

    double min = arr[0];

    double max = arr[0];

    for (int i = 0; i <arr.length;++i){

      average = average + arr[i];

      count++;

      if (arr[i] < min){

        min = arr[i];

      }else if (arr[i] > max){

        max = arr[i];

      }

    }

    System.out.println(max +" "+ min +" "+ average/count );

    

    

  }