2Add to code that after each hand of the game, ask the user if he/she wants to play another hand or not. If a ‘y’ is entered, the program should clear the display on the screen from the previous hand and then play the next hand (whether your program accepts upper case ‘Y’ or not is up to you); otherwise, it terminates.
3) Update the documentation part accordingly and re-compile/execute the program to ensure that you did not accidentally change any other part of the program.
Step 2
Enhance the program so that, after each hand of the game, it asks the user if he/she wants to play another hand or not. Now, assume that only ‘y’ or ‘n’ is a valid input (whether your program accepts upper case ‘Y’ or ‘N’ as a valid input is up to you). If a ‘y’ is entered, the program does the same thing as the previous version; if an ‘n’ is entered, the program should terminate; otherwise, the program should display “Invalid input. Enter only ‘y’ or ‘n’ please:” and have the user re-enter an answer until a valid input is entered. Compile and run the program. Correct any mistakes before proceeding.
3) Enhance the program further so that it also keeps track of the numbers of the total battles that have been played; battles that were won by you, by the opponent, tied, and the percentages in these three categories, respectively. The percentage in each category is equal to (battles in that category) / (total battles)*100. Display on screen these statistics at the end of each battle in the following format. A percentage number should be displayed in decimal notation in a field of 6 spaces with 2 decimal places. All numbers should be aligned correctly based on their significant digits. A sample output is shown at the end of the assignment.
4) Update the documentation part accordingly and re-compile/execute the program to ensure that you did not accidentally change any other part of the program.
[code]
#include
#include
#include
#include
using namespace std;
int main()
{
const int MIN_VALUE = 3; const int MAX_VALUE = 6; int suit; int suit2;
unsigned seed = time(0);
srand(seed);
suit = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE;
suit2 = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE;
const int MIN = 2; const int MAX = 14; int num1; int num2;
unsigned seed1 = time(0);
srand(seed1);
num2 = (rand() % (MAX - MIN + 1)) + MIN;
num1 = (rand() % (MAX - MIN + 1)) + MIN;
What is your actual question? It looks like you're spending too much time trying to make your output look pretty. Do less of that, more actual functionality.
You have the opening code tag. You just need to edit your post and add the closing code tag: [/code]
What's with the empty includes?
Do not call srand() multiple times. srand() sets the RNG to a particular starting point. Calling srand() repeatedly can cause the RNG to return the same random numbers. srand() should be called ONCE at the beginning of main(). http://www.cplusplus.com/reference/cstdlib/srand/
Using the decimal values of the box drawing set makes your code hard to read.
Using enums makes it clear in the code what you're trying to draw.
Step 1
2) Add to code...
3) Update the documentation...
Step 2
x) Enhance the program...
3) Enhance the program further...
4) Update the documentation...
The point of the exercise is not to just show up at the end with the finished result.
It's all about the experience of writing software in incremental steps, testing as you go.
Just giving you the answer won't convey that experience.
It's like eating at a restaurant, and then expecting that will tell you how to cook.
You know what the end result looks like, but you've NO idea how to get there yourself.