CS 1401, Exam #1

Date: Thursday, February 9, 2006
Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. Briefly describe Ada Lovelace's and Alan Turing's contributions to computing. How did the invention of logarithms help computing? For extra credit: describe one more event from the history of computing.

2. At UTEP Union, one burrito costs $1.50; if you buy more than 10, you get a 10% discount. For example, 5 burritos cost 5 x $1.50 = $7.50; 20 burritos cost (20 x $1.50) * (1-10/100) = $30 * 0.9 = $27. Describe, step-by-step, an algorithm that, given the number of burritos, returns the total price of these burritos.

3. For each of the following sequences of symbols, describe which can be valid Java identifiers and which cannot be; if you believe they cannot be, briefly explain why (e.g., "is a reserved word" or "does not start with a letter"):

4-5. Burritos again, this time without a discount. Write a main method that asks a student for the number of burritos, and then computes the total and prints the statement:
For (number) burritos, you pay $(amount).
For example, if you ordered 5 burritos, the computer should print:
For 5 burritos, you pay $7.50.

Reminder: to read strings, you can define the input object as follows:

BufferedReader countryReader = new BufferedReader(new InputStreamReader(System.in));
to convert the string into a real number, you can use the method
Double.parseDouble( )
the header of the main method is:
public static void main(String[] args) throws IOException{

6. Due to the success of the new movie "Wallace and Gromit", many Hollywood studios decided to make similar movies about folks and their dogs. Write down a line of code that, given two strings person (that contains the person's name) and dog (that contains his or her dog's name), places the corresponding movie title into the variable movie. For example, if the contents of the string person is Fred, and the contents of the string dog is Scooby-Doo, then the resulting movie title is "Fred and Scooby-Doo".