#include %26lt;iostream%26gt;
#include %26lt;cstdlib%26gt;
#include %26lt;ctime%26gt;
using namespace std;
int valueOf(card)
{
if (card == 1) return '11'
else if (card %26gt;10) return '13'
else return card
}
char valueOf(card)
{
if (card == 1) card = 'Ace'
else if (card == 2)card = '2'
else if (card == 3)card = '3'
else if (card == 4)card = '4'
else if (card == 5)card = '5'
else if (card == 6)card = '6'
else if (card == 7)card = '7'
else if (card == 8)card = '8'
else if (card == 9)card = '9'
else if (card == 10)card = '10'
else if (card == 11)card = 'Jack'
else if (card == 12)card = 'Queen'
else if (card == 13)card = 'King'
}
int main()
{
srand();
int wager,card1, card2;
cout %26lt;%26lt; "Place your bet\n: ";
cin %26gt;%26gt; wager;
card1 = rand() % 13 + 1;
card2 = rand() % 13 + 1;
cout %26lt;%26lt; "The dealer has\n: " %26lt;%26lt; card1 %26lt;%26lt; "and" %26lt;%26lt; card2 %26lt;%26lt; endl;
cout %26lt;%26lt; "You have\n: " %26lt;%26lt; card1 + card2 %26lt;%26lt; endl;
if (cardscore == 21)
cout %26lt;%26lt; "Congratulations! You got BlackJack!\n: "%26lt;%26lt; endl;
cout %26lt;%26lt; "You win: " %26lt;%26lt; wager* 1.5 %26lt;%26lt; endl;
cout %26lt;%26lt; main %26lt;%26lt; endl;
return 0;
}
I need to know if this code in C++ for a simple BlackJack game is correct, and some help correcting it.?
Looks good, but I heard that you have to put "cout" in the very beginning, but I'm not sure.
Reply:It is not correct.
char valueOf(card) has no return char value.
int valueOf(card)
return '13', this is a char, return 13 is an int type. There is no type specified in valueOf(card)
There are many things wrong with this program
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment