## CS 1401, Quiz #4

**Date:** Tuesday, February 14, 2006

**Class section** (9 am or 10:30 am): ______________________

**Name:**
______________________________________________________________________
1. How did the invention of logarithms help computing?

Logarithms made computations easier because they enabled to reduce
multiplication to an easier operation - addition. The use of
logarithms in computing is based on the fact that log(a*b) = log(a)
+ log(b). So, to compute a*b, we can do the following:
1) find log(a) and log(b),
2) add these two logarithms, thus computing s = log(a)+ log(b); and
3) find a number whose logarithm is equal to this sum s.
This number will be exactly a*b.
This idea formed the base of a slide rule, which for several
centuries was the main computational tool of engineers.

2. At UTEP, a burrito costs $1.50.
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 in = **new** BufferedReader(**new** InputStreamReader(System.in));

to
convert the string into an integer, you can use the method
Integer.parseInt( )

the header of the *main* method is:
**public** **static** void main(String[] args) **throws** IOException{

public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter the number of burritos");
String reads = in.readLine();
int burritos = Integer.parseInt(reads);
System.out.println("For "+ buritos+" burritos, you pay $" +
1.50 * (double) burritos+ ".";
}