[sorry this is a long one] Hello, I know I'm becoming a regular here but I am just not getting it and I am so sorry to keep bugging you guys with what I'm sure are silly problems/questions. I'm new to C++ and programming all together and I decided to join an accelerated class to start with (regretting this decision now).
My problems/issues with this Coin Flip assignment is figuring out how how to build and call my functions appropriately them from main().
The instructions are as follows:
Write a program that starts a player off with a bank of $15.00. A coin will flip and randomly choose heads or tails. The user will guess heads or tails to win. If the coin flip matches the player's guess his bet will be doubled. It costs 1 dollar to play and the program will bet that amount automatically each time as long as there is the available bank amount.
Note: Do not let the game begin if the user's bank amount is below $1.00. This is a large assignment. You should be using plenty of functions, random numbers, decision statements, the while loop(s) (not a dowhile loop), unsigned variables, and i/o manipulation at a minimum.
At the end of the game, ask the user if he/she would like to play again and loop the game with bet input sequence again until the bank reaches 0.00 or the user inputs "n" to quit playing.
Here's what will earn point deductions:
Too few functions (This should have at least 3). Don't be afraid to use functions to help modularize the parts to this game.
Global variables ( no00000oooooooooooOOOOOoo! Darth Vader )
Too many win case evaluations. There should only be if you win or lose. Do not check against both heads and tails and this, and that. You will create a permutation of every outcome. This is not a smart approach. Think, how do you win? You win if your guess is == to the coin flip. I'll say no more.
Syntax errors
Improper logic or improper function arguments/return type
Duplication of code. If you're writing the same thing twice, you're not leveraging functions or proper logic.
Round peg, square hole. i.e. Don't use a for loop and try and convert it to a while loop. Use the right tool for the job.
The completed program should look like the following:
Welcome to the coin flip game.
It will cost 1 dollar to play
If you guess correctly, you will match your bet one to one
Would you like to play? <y/n>
y
Guess heads or tails and I will tell you if guessed correctly <h/t>
h
The coin landed on Tails
I am sorry, but you did not win this time.
Your bank balance is :$14.00
Would you like to play again? <y/n>
y
Guess heads or tails and I will tell you if you guess correctly <h/t>
t
The coin landed on Tails
YOU WIN $2.00
Your bank balance is :$16.00
Would you like to play again? <y/n>
n
Thank you for playing. Your bank balance is $16.00
Press any key to continue . . .
