CS 1401, Quiz #5

Date: Tuesday, February 15, 2005
Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. Write down a method that computes the cotangent cot(x) as the ratio of cos(x) and sin(x). This method should have the following header:

public static double cotangent(double x){





2. To attract more tourists, the city of El Paso decided to officially change the name to Our Beautiful City of El Paso. Because of this change, we must change all the city documents. Describe the code that, given a string document in which the word "El Paso" appears exactly once, replaces the word "El Paso" in this string with the sequence "Our Beautiful City of El Paso". For example, the string
Cars parked illegally in El Paso will be towed away.
should be replaced with a string
Cars parked illegally in Our Beautiful City of El Paso will be towed away.
Hints: The length of a string s can be found as s.length(); a substring can be found as s.substring(first_in,first_out).


















3. What is a Boolean variable? What values can it take? Why do we need Boolean variables?