CS 1401, Quiz #4, version a

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

1. Write down a method that computes the tangent cos(x) as the square root of 1 minus the square of sin(x). This method should have the following header:

public static double cosine(double x){

2. To reflect our true status, our department decided to officially change the name to The Best Department. Because of this change, we must change all the texts which mention the department's name. Describe the code that, given a string text in which the term "Computer Science" appears exactly once, replaces this term in this string with the sequence "The Best". For example, the string
I have just started taking classes at Computer Science Department.
should be replaced with a string
I have just started taking classes at The Best Department.
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?