CS1321 Homework Assignment One

Due Friday, May 25 at 8:00:00am

Any function writen in a homework may be used within the same homework to solve a given problem.
If you need to reuse a solution from a previous homework, you must resubmit the function in the current homework.
Be sure to follow the guidelines as outlines by the homework template and style guidelines documents.

Problem 1
5.0 points

Explain how computer science is different from computer engineering.

 

Problem 2
5.0 points

What character does Scheme use to comment out a line?
Give two good reasons why you would want to comment code.

 

Problem 3
5.0 points

What are the three main programming paradigms?
Which one does Scheme belong in?

 

Problem 4
5.0 points

What does it mean for a function to be one-to-one?
What does it mean for a function to be onto?

 

Problem 5
5.0 points

What symbols does Scheme use to represent true and false?

 

Problem 6
15.0 points

Express each of the following arithmetic expressions as a Scheme expression. Be sure to preserve the standard order of operations.
(the symbol '*' denotes multiplication)

Format your answers like this:

(define (6a) (+ 1 1))
(define (6b) (+ 1 2)) 
a) 1 + 2 + 3 * 4 - 5
b) (19 + 6 - 2) / (3 * 2 * -8)
c) 14 * (3 - 1.2) + -28.6
d) (1 + 3 + 5 + 7 + 9 + 11) * (3 / (4 - 6))
e) (1 + (1 / (1 + (1 / (1 + (1 / 1))))))

 

Problem 7
10.0 points

What is a parameter?
What are the three types of parameters?
Explain the differences between the types.

 

Problem 8
5.0 points

What is a literal?

 

Problem 9
10.0 points

Thoroughly explain the differences between compiled and interpreted languages.

 

Problem 10
5.0 points

What does it mean to talk about the domain of a function?
The range of a function?

 

Problem 11
10.0 points

What is abstraction?
Why is it important?

 

Problem 12
10.0 points

Jo's hardware store sells bolts for $1.25 a pound, nuts for $1.85 a pound and washers for $0.76 a pound.

Write three functions to determine the cost to buy some amount of bolts, nuts, and washers.

Call your functions bolts-cost, nuts-cost, and washers-cost. Example usage:

> (bolts-cost 14)
17.5
> (nuts-cost 13)
24.05
> (washers-cost 11)
8.36

 

Problem 13
5.0 points

Now write a function called hardware-shopping which takes in three parameters in this order

  1. the amount of bolts to buy
  2. the amount of nuts to buy
  3. the amount of washers to buy

It should return the total cost of the items. Example

> (hardware-shopping 14 13 11)
49.91

 

Problem 14
10.0 points

The area of a circle can be approximated by 3.14 times the radius squared.

Write a function called circle-area which takes in a radius and return the area of a circle with that radius. Example:

> (circle-area 1)
3.14
> (circle-area 3)
28.26

 

Problem 15
5.0 points

The volume of a cylider is given by the area of the circle that makes up the base times the height of the cylinder.

Write a function called cylinder-volume which will take in exactly two parameters:

  1. the radius of the base
  2. the height of the cylinder

and will return the volume of the cylinder. Example:

> (cylinder-volume 3 10) 
282.6

 

Problem 16
10.0 points

Explain in your own words what recursion is.


Last Modified: May 20, 2001 by CS1321