COSC 071: Computer Science I

Homework 1
Spring 2000

Due in 1st lecture of week Jan 17-21
2 points

This homework is designed to get you thinking about algorithms, object hierarchies, and object decomposition.

  1. Hoya Pizza sells a 9" square pizza with one topping for $9.99, and Saxa Pizza sells an 10" round pizza with one topping for $8.99. Which is the better buy?

  2. An algorithm is just a step-by-step procedure for accomplishing a task. The steps you took above constitutes an algorithm, albeit a very specific algorithm. A limitation is that it only works for 9" square pizzas that cost $9.99 and for 10" round pizzas that cost $8.99. Instead of using the actual numbers provided, rewrite your previous ``algorithm'' using variables or symbols that represent the numbers. For example, instead of writing 9.99, write Round_Pizza_Cost, and instead of writing 10, write Round_Pizza_Size.

    For example, if we had a triangle pizza, we may write something like:

    The advantage of doing this is that we've separated the procedure for calculating the price per square inch of a pizza from any set of specific numbers. To compute a new price per square inch, we simply reassign the variables that correspond to the cost and the size of the pizza.

  3. Assume that you are restricted to four actions: INPUT, CALCULATE, DECISION, and OUTPUT. Express your algorithm for deciding which pizza is the better buy in terms of these actions.

    For our triangle pizza example, we may write something like:

  4. A bicycle consists of many different parts.

  5. In a university, there are many different types of people. There are employees and students, but there are also different types of employees and different types of students. All of the people of a university have something in common: a name. All employees have a salary. All students have something in common also. Draw a hierarchy for people in a university. (Draw nodes for as many different types of people as you can.) At each node in the hierarchy, list at least one property common to everyone who follows in the hierarchy. Here's a start: