CS 101 Homework 4
Assigned Week of February 12, 2001 -- Due at Beginning of Lab the Week of February 26, 2001
Pledge: This assignment is pledged. You may discuss its content and your approach with anyone, but you must do all your own work. You must create the logic of the solution, type your own code, and compile, execute, and debug your own program. You may not use any code developed by anyone else. Your source code and executable code submitted electronically must match exactly the code you deliver in your lab section.
Be aware that although you have two weeks to do this assignment it is to your advantage to have it done prior to the test. The experience with loops will prove helpful. In addition, most likely another assignment will be given next week.
The purpose of this homework is to familiarize you with conditional loops and function calls that exist in all realistic programs.
You are the programmer at a casino in Atlantic City. You have been tasked to develop a computer program that can play Ace-High, a card game similar to, but simpler than, blackjack. The rules and procedures are as follows.
WELCOME TO THE ACE-HIGH GAMEPlayer draws 11 and 11, total 22.Dealer wins.Play again (y or n)? yWELCOME TO THE ACE-HIGH GAMEPlayer draws 8 and 10, total 18.Dealer draws 9 and 11, total 20.Dealer wins.Play again (y or n)? y
WELCOME TO THE ACE-HIGH GAMEPlayer draws 7 and 4, total 11.Dealer draws 5 and 9, total 16.Dealer draws 2, total 18.Dealer wins.Play again (y or n)? yWELCOME TO THE ACE-HIGH GAMEPlayer draws 10 and 10, total 20.Dealer draws 5 and 6, total 11.Dealer draws 5 and 9, total 25.Player wins.Play again (y or n)? yWELCOME TO THE ACE-HIGH GAMEPlayer draws 8 and 9, total 17.Dealer draws 10 and 7, total 17.Player draws 9.Dealer draws 7.Player wins.Play again (y or n)? yWELCOME TO THE ACE-HIGH GAMEPlayer draws 9 and 10, total 19.Dealer draws 11 and 2, total 13.Dealer draws 2, total 15.Dealer draws 4, total 19.Player draws 5.Dealer draws 10.Dealer wins.Play again (y or n)? xGame ended at player's request.
The program shell (the uncompleted Ace-High program) is available at our CS 101 website. In the program shell, there is a function named get_card() that will return a value in the range of 2 to 11 each time it is called. To use this function, store its value into an integer value like this:
int my_card;// my_card will be assigned a value in the range 2 to 11my_card = get_card();
The program shell shows you where to place your programming with respect to the get_card() function.
A draft grading criteria is available.
Submissions
When your program is finished, name the source hw4.cpp and the executable hw4.exe (you must use exactly these names!) and submit it to the graduate TA of your lab section .