Comp200 – Elements of Computer Science EXAM #1October 5, 2005
RiceUniversity - Instructor: Dung NguyenNAME & ID#: ______
Instructions
- This is an open-note, open-book exam.
- You are free to use any materials that were given to you in the lectures.
- You are free to use DrScheme and EXCEL and any on-line help materials that these software provide.
- When you are done, upload all of your work to the “Exam1” assignment on the course WEBCT.
- There are three problems for a total of 100 points.
- You have 50 minutes to complete the exam.
Please write and sign the Rice Honor Pledge here:
/15 pts / /15 pts / /15 pts / /15 pts / /5 pts / /35 pts / /100 pts
1. The following is the postage rate for first class mail in the USA.
- $0.37 for the first ounce.
- $0.23 for each additional ounce.
a/ Design an EXCEL spreadsheet that produces the postagecostin US $ given the weight in ounces of the mail item. The spreadsheet should clearly have cells containing problem constants, cells containing all the variables of the problem and cells containing all relevant formulas. All the cells must be clearly labeled. Use the IF function.
b/ Design a Scheme program consisting of one or more Scheme functions that computes the same thing. Be sure to define the appropriate problem constants and write the complete design recipe for each function you write.
2. Consider the following logic word problem (from Principles of Computer Science by Cullen Schaffer).
- Peter will go to the bankif and only if Richard does the shopping and Sally sweeps up.
- Sally will sweep up if and only if Tom and Victormake the bed.
- Tom agrees to make the bed, but Richard refuses to go shopping.
- What will Peter do?
a/ Design a logic circuit to represent the above problem. Draw the circuit by hand on a separate sheet of paper. Be sure to turn in the paper at the end of the exam.
b/ Design an EXCEL spreadsheet that solves the above problem. The spreadsheet should clearly have cells containing problem constants, cells containing all the variables of the problem and cells containing all relevant formulas. All the cells must be clearly labeled.
c/ List all the situations where Peter will go to the bank.
3. Pizza Mania is having a special on the same kind of pizza (i.e. same thickness and same ingredients). The special comes in two shapes: rectangular (4" by 6") for $4.99 and round (5" in diameter) for $3.99. Which one is the better deal? You are to solve this problem in the following manner.
- First, compute the price per unit area for each of the pizza. This price per unit area represents the notion of a “deal.”
- Second, compare the price per unit area (ppua) of the rectangular pizza against that of the round pizza. If the ppua of the rectangular pizza is less or equal to the ppua of the round pizza, then return true, meaning the rectangular pizza is a better deal, otherwise return false.
Solve the above problem using either EXCEL or Scheme (not both).
- If you use EXCEL, your spreadsheet must clearly have cells containing problem constants, cells containing all the variables of the problem and cells containing all relevant formulas. All the cells must be clearly labeled.
- If you use Scheme, you only need to write the contract, header, purpose and definition of each of the functions involved. You need not write the examples and tests.
10/24/20181 of 2