Class LP1


public class LP1 extends Object
Glorious Lab Practical on Java
  • Constructor Details

    • LP1

      public LP1()
  • Method Details

    • sum

      public static BigInteger sum(ArrayList<BigInteger> a)
      This computes the sum of a list of BigIntegers
      Parameters:
      a - an array list of BigIntegers
      Returns:
      the sum of the BigIntegers in a
    • aerate

      public static String aerate(String s, int p)
      This plucks out entries of a string at indices divisible by p. in a string.
      Parameters:
      s - a string
      p - a nonnegative integer.
      Returns:
      a string that has entries p, 2p, 3p, etc of the string s. Examples: aerate("aardwolf" 2) -> "arwl" aerate("bacchanalia" 3) -> "bcni"
    • echoy

      public static String echoy(String s)
      This makes a string echoy. See the example
      Parameters:
      s - is a string
      Returns:
      a string with the nth character repeated n times. example: echoy("cowpie") → coowwwppppiiiiieeeeee if the string passed is empty, return an empty string
    • finger

      public static int finger(ArrayList<BigInteger> a)
      This computes the product of the non-zero elements of a and returns the sum of its digits.
      Parameters:
      a - an array list
      Returns:
      the sum of the digits in the product of the non-zero entries in a
    • pseudoGrep

      public static ArrayList<String> pseudoGrep(ArrayList<String> al, String s)
      This filters strings for a specified substring
      Parameters:
      al - is an array list of strings.
      s - is a search string
      Returns:
      an array list of striings containing all those strings in the array list al having s as a substring.
    • daysFromNow

      public static LocalDate daysFromNow(int n)
      This finds the date n days from today. If n is negative find the date -n days ago.
      Parameters:
      n - the number of days from today
      Returns:
      the date n days from today. Sample: 10000 days from this lab prac is 29 March 2049. Today is 11 November 2021 Sample: 10000 days ago is 1994-06-26
    • main

      public static void main(String[] args)
      Here is your testing ground.
      Parameters:
      args - command-line arguments. You won't have any.