Homework 2: Basic Algorithms
Out: Monday, September 22, 2008
Due: Monday, September 29, 2008, at the beginning of class.
Note that late homeworks will NOT be accepted.
Objectives:
- To practice solving problems in a generic manner
- To practice writing basic pseudocode for the solution of a problem
Assignment:
- First solve each of the two problems shown below. (25 points each,
so make sure you show your work, no matter how simple you think it is)
- Then write an algorithm for each of these two problems in pseudocode.(25
points each)
1) Mr. Jones went on a gambling spree one night. He went to a casino
and paid $5.00 admission to enter. While gambling, he lost half his money.
He left and had to pay $5.00 for parking. He went to another casino,
paid $5.00 admission to enter, and again, promptly lost half his remaining money. After he left that casino
and paid another $5.00 for parking, he found he had no money left. How much money
did Mr. Jones have when he started the night? Would he have been better off investing in credit default swaps? :-)
Tips about problem # 1 :
- Mr. Jones must always have no money left at the end.
- The user should specify the number of casinos.
- The user should specify the admission fee to enter the casino.
You can assume it will be the same for every casino.
- The user should specify the parking fee. You can assume
it will be the same each time he retrieves his car.
2) Your grade in CMSC104 is based on the following:
3 Homeworks (4% each) = 12%
4 Projects (7% each) = 28%
3 Exams (20% each) = 60%
Total = 100%
If you have the following homework, project and exam grades at the end of
the semester, calculate your final grade for the course:
Homework 1 = 100/100 Project 1 = 90/100 Exam 1 = 90/100
Homework 2 = 50/100 Project 2 = 100/100 Exam 2 = 85/100
Homework 3 = 100/100 Project 3 = 95/100 Exam 3 = 80/100
Project 4 = 95/100
Tips about problem # 2 :
- You should allow the user to enter in each of
the homework, project and exam grades individually.