PracticeLP1.java

Practice LP1

Here is the shell code. It runs out of the box.


import java.util.ArrayList;
import java.util.Arrays;
import java.math.BigInteger;
import java.math.BigDecimal;
/**
*  Glorious Lab Practical on Java
*/
public class PracticeLP1
{
    /** 
     * This computes  the sum of a list of BigIntegers
     * @param a an array list of BigIntegers
     * @return the sum of the BigIntegers in a
     */
    public static BigInteger sum(ArrayList<BigInteger> a)
    {
        return BigInteger.ZERO;
    }
    /**
    * This plucks out entries of a string at indices divisible by p.
    * in a string.  
    * @param s a string
    * @param p a nonnegative integer.  
    * @return a string that has entries p, 2p, 3p,   etc of the
    * string s.
    *  Examples:
    * aerate("aardwolf" 2) -&gt; "arwl"
    * aerate("bacchanalia" 3) -&gt; "bcni"
    */
    public static String aerate(String s, int p)
    {
        return "";
    }
    /**
     * This makes a string echoy.  See the example
     * @param s is a string
     * @return a string with the nth character repeated n times.  
     * example:  echoy("cowpie") &rarr; coowwwppppiiiiieeeeee
     * if the string passed is empty, return an empty string
     */
    public static String echoy(String s)
    {
        return "";
    }
    /** 
     * This computes the product of the non-zero elements of
     * a and returns the sum of its digits.
     * @param a an array list
     * @return the sum of the digits in the product of the 
     * non-zero entries in a
     */
    public static int  finger(ArrayList<BigInteger>  a)
    {
        return 0;
    }
    /**
     * This filters strings for a specified substring
     * @param al is an array list of strings.
     * @param s is a search string
     * @return an array list of striings containing all those strings
     * in the array list <code>al</code> having <code>s</code> as a substring.
     */
     public static ArrayList<String> pseudoGrep(ArrayList<String> al, String s)
     {
         return new ArrayList<String>();
     }
    /**
    *  @param num is a nonnegative integer
    *  @param denom is a nonnegative integer whose only prime factors
    *  are 2 or 5 
    *  @return a string reprsesentation of the exact decimal
    *  expansion of num/denom.
    *  The BigDecimal class can help you with this!
    *  You will need to scrach around on its API page.
    */
    public static String exactQuotient(int num, int denom)
    {
        return "";
    }
    /** 
    *  Here is your testing ground.
    *  @param args command-line arguments. You won't have any.
    */
    public static void main(String[] args)
    {
        System.out.println(exactQuotient(1, 268435456).equals("0000000037252902984619140625"));
    }
}