/** Functions for lab 09. CS1110 */ public class Loops { /** Yields: "p is a prime." i.e. p is at least 2 * and is divisible by only 1 and itself */ public static boolean isPrime(int p) { if (p < 2) { return false/*change the expression, if necessary */; } if (p == 2) { return false/*change this expression, if necessary */; } // Return false if some integer in 2..p-1 divides p // inv: p is not divisible by integers in 2..k-1 for (int k= 0/* change this expression, if necessary */; k < p; k= k+1) { if ( false /*change this expression */ ) { return false; } } // no integer in 2..p-1 divides p return false/*change this expression */; } /** Yields: a String that contains each capital letter (in * 'A'..'Z') whose representation is prime */ public static String primeChars() { String s= null; // change this expression // inv: s contains each capital in 'A'..c-1 // whose representation is prime for (char c = ' '/*change expr */; c <= ' '/*change expr */; c++) { if ( false /*change this expr */ ) { s= s + ""/*change expr */; } } // {s contains each capital in 'A'..'Z' whose rep is a prime} return s; } /** Yields: number of times character c appears in String s */ public static int noOfTimes(char c, String s) { return 0; } /** Yields: number of times the characters in s1 appear in s2 * e.g. noOfTimes("aeiou", st) * gives the number of vowels in string st * e.g. noOfTimes("aaab", "ac") is 3 */ public static int noOfTimes(String s1, String s2) { return 0; } }