CMSC 104, Spring 2011
Homework 2
Basic Algorithms
Out: Tuesday 2/22/11
Due at the beginning of the class period:
Thursday 3/3/11
Note that late homeworks will NOT be accepted.
The Objectives
- To practice solving problems in a generic manner
- To practice writing basic pseudocode for the solution of a problem
The Assignment
- The answer to each problem will have two parts: the specific solution and the general solution.
- You do not have to do any error checking of user input.
- First solve each of the two problems shown below. You should show the specific answer to the problem using the numbers given. (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)
- Mrs. Smith is on a cruise to the Bahamas. On a rainy day, she decides to go to the casino bar and play blackjack. She pays a $5.00 cover charge to enter the casino bar. She plays at one table, doubles her money and tips the dealer $10.00. She goes again the next day, pays a $5.00 cover charge and doubles her money. After tipping the dealer $10.00, she runs out of money. How much money did she start with?
- Mrs. Smith must always have no money left at the end.
- The user should specify the number of days she plays blackjack.
- The user should specify the cover charge to enter the casino bar. You can assume it will be the same for each day.
- The user should specify the amount of the tip. You can assume it will be the same each time she plays.
Tips about problem # 1 :
- Your grade in CMSC104 is based on the following:
4 Homeworks (4% each) = 16% 3 Projects (8% each) = 24% 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 = 85/100 Exam 1 = 95/100 Homework 2 = 75/100 Project 2 = 75/100 Exam 2 = 85/100 Homework 3 = 100/100 Project 3 = 70/100 Exam 3 = 70/100 Homework 4 = 80/100
Tips about problem # 2 :- You should allow the user to enter in each of the homework, project and exam grades separately
- You can assume the percentages will always be 4%, 8% and 20%. You should not ask the user to enter in these values.