14 Replies - 2969 Views - Last Post: 27 September 2009 - 12:42 PM Rate Topic: -----

#1 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Need help with pseudocode and what to enter in c++

Posted 26 September 2009 - 11:58 PM

here is what I have so far:


//Specification: This program plays a version of
//the card game of 21.
//A human player is pitted against the computer.
//The player who is the closest to 21 without
//going over wins the hand. 
#include <iostream>
#include <ctime>
#include <string>

using namespace std;

//prototypes...
void play21(void);
int dealCards(int, string);
void hit(int &);
void determineWinner(int, int);
int Random(int, int);


void main(){

	   char keepPlaying = 'n'; //loop control variable

	   do {
			  play21();
		  
			  //keep playing?
			 cout << "Do you want to play anouther hand (y/n)?";
			 cin >> keepPlaying;
	 } while(keepPlaying == 'Y' || keepPlaying == 'y');
}

void play21(void){
		//play one hand of 21

		//randomize the cards
		srand((int) time(0));

	   // deal the cards
		 int person = dealCards(2, "Your Cards:");
		 cout << " = " << person << endl;
		 int house = dealCards(2, "Computers Cards:");
		 cout << " = " << house << endl;

		// Ask if human wants a hit and keep hitting...
		hit(person);
		cout << endl;

	   //Determine if computer takes a hit
	   while ((house < person) && (house <= 21) && (person <= 21)) {
			   house += dealCards(1, "The Computer takes a card ");
			   cout << endl;
		}

	   //show who won....
	   determineWinner(person, house);
}

void determineWinner(int humanScore, int houseScore) {
//Compare the scores to see who won
	if (int humanScore > int houseScore && humanScore <= 21)
		cout << "You Win!";
	cout << humanScore & houseScore << endl;
	if (int humanScore == int houseScore)
		cout << "Tie You Both Win!";
	cout << humanScore & houseScore << endl;
	else (int humanScore < int houseScore && houseScore <=21)
		cout << "You Lose!";
	cout << humanScore & houseScore << endl;

//Both the human and the house score totals are provided as arguments

//Display total scores and indicate winner

//possible outcomes: human wins, computer wins, tie

}

int dealCards(int numberOfCards, string message){
//This function deals the cards

//The number of cards to be dealt is provided as an argument for loop and call random,
	//need single card and accumulator, for loop is # of cards=52 then call randome
	for (int numberOfCards = 52)
		random();
//A message indicating which player is receiving the cards is also
//given as an argument

//The player message and the cards dealt is displayed to the screen, output cards


//the total value of the dealt cards  is returned, return accumulator

}

void hit(int &playerScore){
//This function asks the human if they want another card -- 'a hit'
//the player's score total is accumulated as they take cards

//the player can continue taking cards until they wish to stop or they exceed 21

//After a card is taken (use the dealCards function) the user's current total is displayed

//If the user goes over 21 'busted' is displayed


Start

	 // hit = yes = variable
	 char hit = y || Y

	  while loop (until hit)

				  if the player has not busted

						//Does the player want a hit?
						cout << "Do you want to hit";

						if players wants hit
						Add playerscores to **dealcard function** output, call dealcard function

						else players does not want hit

							  cout << "You decide to stand";

						if the player has busted

						cout << "You have gone over 21, You Lose";

					  char  hit = n || N

		End of while loop								 

End


}

int Random(int lowerLimit, int upperLimit) {
//returns a random number within the given boundary
		 return 1 + rand() % (upperLimit - lowerLimit + 1);
}




I'm lost in the hit, and dealcards function, I believe I have done the determineWinner function correctly

can anyone assist me?

Is This A Good Question/Topic? 0
  • +

Replies To: Need help with pseudocode and what to enter in c++

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:12 AM

What sort of help would you like?

You'll find that the more specific your question the more specific (and helpful) the answers you will receive.

As a starting place here's a few compiler errors in what you have posted that need some attention:

DIC.cpp:21: error: ‘::main’ must return ‘int’
DIC.cpp: In function ‘void determineWinner(int, int)’:
DIC.cpp:62: error: expected primary-expression before ‘int’
DIC.cpp:62: error: expected `)' before ‘int’
DIC.cpp:64: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator<<’
DIC.cpp:65: error: expected primary-expression before ‘int’
DIC.cpp:65: error: expected `)' before ‘int’
DIC.cpp:67: error: invalid operands of types ‘int’ and ‘<unresolved overloaded function type>’ to binary ‘operator<<’
DIC.cpp:68: error: expected `}' before ‘else’
DIC.cpp: At global scope:
DIC.cpp:68: error: expected unqualified-id before ‘else’
DIC.cpp:70: error: expected constructor, destructor, or type conversion before ‘<<’ token
DIC.cpp:78: error: expected declaration before ‘}’ token
Was This Post Helpful? 0
  • +
  • -

#3 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:29 AM

basically what to fill in at the green comments

here is the sample of the output I need :

Your Cards: 5 6 = 11
Computers Cards : 4 5 = 9

Do you want another card (y/n)? y
Hit: 5 Your total is 16

Do you want another card (y/n)? y
Hit: 4 Your total is 20

Do you want another card (y/n)? n

The computer takes a card: 9

The computer takes a card: 5

Your score: 20
Computer score: 23

You Won!


to tell you the truth I'm completely lost on this one grrrrr;(


I believe I am stating this argument incorrectly

if (int humanScore > int houseScore && humanScore <= 21);



I believe the above due to this error

Error 1 error C2059: syntax error : '>' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 61
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:36 AM

Well you are going to have to return to the basics of how to write C++ if you are going to get this done.

Once you have some of the basic syntax sorted out you will be better able to solve the logic puzzles that have been set you.

What is this?
void main(){

and this?
if (int humanScore > int houseScore && humanScore <= 21)

Where are your braces "{" and "}" in this?
 if (int humanScore > int houseScore && humanScore <= 21)
        cout << "You Win!";
    cout << humanScore & houseScore << endl;
    if (int humanScore == int houseScore)
        cout << "Tie You Both Win!";
    cout << humanScore & houseScore << endl;
    else (int humanScore < int houseScore && houseScore <=21)
        cout << "You Lose!";
    cout << humanScore & houseScore << endl;



Until you can get some code that compiles for the part you think you have done there is little point trying to do more.

Comment out all the code for the functions you aren't yet ready to try and just do some work on getting the determineWinner() function to compile and then get it to produce the output you want.

What you have posted so far is just characters on a page that look slightly like C++ but aren't really code.
Go slowly step by step and try and turn what you have into code that compiles.

Ask specific questions about the bits you get stuck on.
Was This Post Helpful? 0
  • +
  • -

#5 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:48 AM

This may be a dumb question but lets say I take the one function definition I have going hopefully almost correctly can I put into a cpp file and see how it built or must I include all variables and the main plus the function definition? I 'm thinking I need to look at this at just these function sections 1 at a time and build them one at a time to see how it works. I know main is correct but my function definitions are not. It's my last exercise for class, I have to work tomorrow from 12-11, and when I get home that just gives me enough time to turn in my homework and my quiz (this here is homework) I have a 99.9% so far thanks to my own genius and everyone else here and I really do appreciate all your help but I'm starting to go brain dead due to lack of sleep LOL:) I guess I know what it feels like now in the programmming world.

I believe it should look like this for the one section that I've got almost figured out


void determineWinner(int humanScore, int houseScore) {
//Compare the scores to see who won
	if (int humanScore > int houseScore && humanScore <= 21){
		cout << "You Win!";
	cout << humanScore & houseScore << endl;
	}
	if (int humanScore == int houseScore){
		cout << "Tie You Both Win!";
	cout << humanScore & houseScore << endl;
	}
	else (int humanScore < int houseScore && houseScore <=21){
		cout << "You Lose!";
	cout << humanScore & houseScore << endl;
	}




this portion was given to us:


//Specification: This program plays a version of
//the card game of 21.
//A human player is pitted against the computer.
//The player who is the closest to 21 without
//going over wins the hand. 
#include <iostream>
#include <ctime>
#include <string>

using namespace std;

//prototypes...
void play21(void);
int dealCards(int, string);
void hit(int &);
void determineWinner(int, int);
int Random(int, int);


void main(){

	   char keepPlaying = 'n'; //loop control variable

	   do {
			  play21();
		  
			  //keep playing?
			 cout << "Do you want to play anouther hand (y/n)?";
			 cin >> keepPlaying;
	 } while(keepPlaying == 'Y' || keepPlaying == 'y');
}

void play21(void){
		//play one hand of 21

		//randomize the cards
		srand((int) time(0));

	   // deal the cards
		 int person = dealCards(2, "Your Cards:");
		 cout << " = " << person << endl;
		 int house = dealCards(2, "Computers Cards:");
		 cout << " = " << house << endl;

		// Ask if human wants a hit and keep hitting...
		hit(person);
		cout << endl;

	   //Determine if computer takes a hit
	   while ((house < person) && (house <= 21) && (person <= 21)) {
			   house += dealCards(1, "The Computer takes a card ");
			   cout << endl;
		}

	   //show who won....
	   determineWinner(person, house);
}




here is what the exercise looks like:


To complete this exercises, provide the required code for the following functions: dealCards, hit, and determineWinner.



//Specification: This program plays a version of
//the card game of 21.
//A human player is pitted against the computer.
//The player who is the closest to 21 without
//going over wins the hand. 
#include <iostream>
#include <ctime>
#include <string>

using namespace std;

//prototypes...
void play21(void);
int dealCards(int, string);
void hit(int &);
void determineWinner(int, int);
int Random(int, int);


void main(){

	   char keepPlaying = 'n'; //loop control variable

	   do {
			  play21();
		  
			  //keep playing?
			 cout << "Do you want to play anouther hand (y/n)?";
			 cin >> keepPlaying;
	 } while(keepPlaying == 'Y' || keepPlaying == 'y');
}

void play21(void){
		//play one hand of 21

		//randomize the cards
		srand((int) time(0));

	   // deal the cards
		 int person = dealCards(2, "Your Cards:");
		 cout << " = " << person << endl;
		 int house = dealCards(2, "Computers Cards:");
		 cout << " = " << house << endl;

		// Ask if human wants a hit and keep hitting...
		hit(person);
		cout << endl;

	   //Determine if computer takes a hit
	   while ((house < person) && (house <= 21) && (person <= 21)) {
			   house += dealCards(1, "The Computer takes a card ");
			   cout << endl;
		}

	   //show who won....
	   determineWinner(person, house);
}

void determineWinner(int humanScore, int houseScore) {
//Compare the scores to see who won
//Both the human and the house score totals are provided as arguments
//Display total scores and indicate winner
//possible outcomes: human wins, computer wins, tie

}

int dealCards(int numberOfCards, string message){
//This function deals the cards
//The number of cards to be dealt is provided as an argument
//A message indicating which player is receiving the cards is also
//given as an argument
//The player message and the cards dealt is displayed to the screen
//the total value of the dealt cards  is returned

}

void hit(int &playerScore){
//This function asks the human if they want another card -- 'a hit'
//the player's score total is accumulated as they take cards
//the player can continue taking cards until they wish to stop or they exceed 21
//After a card is taken (use the dealCards function) the user's current total is displayed
//If the user goes over 21 'busted' is displayed

}

int Random(int lowerLimit, int upperLimit) {
//returns a random number within the given boundary
		 return 1 + rand() % (upperLimit - lowerLimit + 1);
}
 



Here is the pseudo code for hit function:

Start

hit = yes

while loop (until hit)

If the player has not busted

Does the player want a hit?

If players wants hit

Add playerscores to dealcard function output

If players does not want hit

Display

If the player has busted

Display

hit = No

End of while loop

End
Was This Post Helpful? 0
  • +
  • -

#6 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 01:06 AM

I basically have to just figure out the 3 functions I believe i have the determineWinner one almost correct but the other 2 I am highly confused on.

With the pseudocode above I believe it will go something like this for the hit function


char hit = y||n
// Begin while loop
while (char hit == y){
if (humanScore <= 21) {		 //player has not busted
cout << "Do you want to take a hit?";
}
if (char hit == y){					 //player wants hit
cout << humanScore + dealCard() // adds humanScore to dealCard()
else{										   //players does not want hit
cout << "You decide to stand";
if (humanScore > 21){					//player has busted
cout << "You have gone over 21, You Lose";
}   //end if
}  //end else
} // end while




does this part sound right?
Was This Post Helpful? 0
  • +
  • -

#7 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 01:17 AM

Here's the function you say you think is pretty much done.

I have stripped away all the other stuff and given it your includes and using statement and a minimum main() so it can compile when you turn it into lines of C++ code instead of stuff that looks vaguely like C++ but really isn't.

Unless and until you can get this to compile there is no point looking at other code.

#include <iostream>
#include <ctime>
#include <string>

using namespace std;


void determineWinner(int humanScore, int houseScore) {
//Compare the scores to see who won
    if (int humanScore > int houseScore && humanScore <= 21){
        cout << "You Win!";
    cout << humanScore & houseScore << endl;
    }
    if (int humanScore == int houseScore){
        cout << "Tie You Both Win!";
    cout << humanScore & houseScore << endl;
    }
    else (int humanScore < int houseScore && houseScore <=21){
        cout << "You Lose!";
    cout << humanScore & houseScore << endl;
    }
}

int main() {
	// just a test harness
	return 0;
}                            


Was This Post Helpful? 0
  • +
  • -

#8 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 01:28 AM

Having looked at your earlier code I thought I may not have made the idea of a test harness obvious enough so try this:
#include <iostream>
#include <ctime>
#include <string>

using namespace std;


void determineWinner(int humanScore, int houseScore) {
//Compare the scores to see who won
    if (int humanScore > int houseScore && humanScore <= 21){
        cout << "You Win!";
    cout << humanScore & houseScore << endl;
    }
    if (int humanScore == int houseScore){
        cout << "Tie You Both Win!";
    cout << humanScore & houseScore << endl;
    }
    else (int humanScore < int houseScore && houseScore <=21){
        cout << "You Lose!";
    cout << humanScore & houseScore << endl;
    }
}

int main() {
	// just a test harness  
	
	cout << endl << "test1 22/20" << endl;
	determineWinner(22, 20);
	
	cout << endl << "test2 21/21" << endl;
	determineWinner(21, 21);
	
	cout << endl << "test3 20/22" << endl;
	determineWinner(20, 22);
	
	cout << endl << "test4 19/20" << endl;
	determineWinner(19, 20);
	
	cout << endl << "__________" << endl << endl;
	
	return 0;
}




I haven't covered all the cases but think through all the cases and ensuring your function handles them correctly should be easy enough given these examples.
Was This Post Helpful? 0
  • +
  • -

#9 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 01:31 AM

ok I'll try working with this and see what happens can I do this for my other 2 functions as you have done for me?

I'm not sure if I need to do cases if I do that is why I was so lost, cause I could make all the cases very easily, but I believe they want us to do it without using cases, I'll try the first part you sent so I can see what happens, thanks for the help Idefinitely appreciate it:)
Was This Post Helpful? 0
  • +
  • -

#10 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 02:34 AM

need help with this part of function for I do not understand the logic some tips would be great:


int dealCards(int numberOfCards, string message){
//This function deals the cards
//The number of cards to be dealt is provided as an argument
//A message indicating which player is receiving the cards is also
//given as an argument
//The player message and the cards dealt is displayed to the screen
//the total value of the dealt cards  is returned
   
}




right now with this code


//Specification: This program plays a version of
//the card game of 21.
//A human player is pitted against the computer.
//The player who is the closest to 21 without
//going over wins the hand. 
#include <iostream>
#include <ctime>
#include <string>

using namespace std;

//prototypes...
void play21(void);
int dealCards(int, string);
void hit(int &);
void determineWinner(int, int);
int Random(int, int);


void main(){ 

	   char keepPlaying = 'n'; //loop control variable

	   do {
			  play21();
		  
			  //keep playing?
			 cout << "\nDo you want to play another hand (y/n)?";
			 cin >> keepPlaying;
	 } while(keepPlaying == 'Y' || keepPlaying == 'y');
}

void play21(void){
		//play one hand of 21

		//randomize the cards
		srand((int) time(0));

	   // deal the cards
		 int person = dealCards(2, "Your Cards:");
		 cout << " = " << person << endl;
		 int house = dealCards(2, "Computers Cards:");
		 cout << " = " << house << endl;

		// Ask if human wants a hit and keep hitting...
		hit(person);
		cout << endl;

	   //Determine if computer takes a hit
	   while ((house < person) && (house <= 21) && (person <= 21)) {
			   house += dealCards(1, "The Computer takes a card ");
			   cout << endl;
		}

	   //show who won....
	   determineWinner(person, house);
}  

void determineWinner(int humanScore, int houseScore) {
														//Compare the scores to see who won
	if ((humanScore > houseScore) && (humanScore <= 21)){
		cout << "You Win!";
	cout << humanScore << houseScore << endl;
	}
	if (humanScore == houseScore){
		cout << "Tie You Both Win!";
	cout << humanScore << houseScore << endl;
	}
	else ((humanScore < houseScore) && (houseScore <=21)){
		cout << "You Lose!";
	cout << humanScore << houseScore << endl;
	}

int dealCards(int numberOfCards, string message){
//This function deals the cards
//The number of cards to be dealt is provided as an argument
//A message indicating which player is receiving the cards is also
//given as an argument
//The player message and the cards dealt is displayed to the screen
//the total value of the dealt cards  is returned
   
}

void hit(int &playerScore){


char hit = 'y'||'n';
// Begin while loop
while (char hit == y){
if (humanScore <= 21) {		 //player has not busted
cout << "Do you want to take a hit?";
}
if (char hit == y){					 //player wants hit
cout << humanScore + dealCard() // adds humanScore to dealCard()
else{										   //players does not want hit
cout << "You decide to stand";
if (humanScore > 21){					//player has busted
cout << "You have gone over 21, You Lose";
}   //end if
}  //end else
} // end while


}
}


int Random(int lowerLimit, int upperLimit) {
//returns a random number within the given boundary
		 return 1 + rand() % (upperLimit - lowerLimit + 1);
}




I am getting these errors:

Error 1 error C2143: syntax error : missing ';' before '{' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 69
Error 2 error C2601: 'dealCards' : local function definitions are illegal c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 74
Error 3 error C2601: 'hit' : local function definitions are illegal c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 84
Error 4 error C2601: 'Random' : local function definitions are illegal c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 108
Error 5 fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp(59)' was matched c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 112

I'm getting closer if I could figure out this dealCard function it might help getting rid of the errors I am receiving, any help is appreciated, assignment is due in 18 hrs
Was This Post Helpful? 0
  • +
  • -

#11 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 02:41 AM

I really need to know why I am getting a syntax error here this is the main error I need assistance on

Error 1 error C2143: syntax error : missing ';' before '{' c:\documents and settings\hp_administrator.wilson\my documents\visual studio 2008\projects\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3\wilsoniii_lab4_exercise3.cpp 69
Was This Post Helpful? 0
  • +
  • -

#12 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 08:59 AM

can anyone help? I'm now at work so I do not have a compiler any asssistance would be great on how to do the dealCard function, thanks
Was This Post Helpful? 0
  • +
  • -

#13 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:29 PM

nevermind I believe I got the code working will have to check when I get home wish me luck;)
Was This Post Helpful? 0
  • +
  • -

#14 Gmoney93079  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 257
  • Joined: 19-September 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:37 PM

ps thanks for all your help, hopefully one day I will be like all of you and be able to assist people with inquiries, cout;)
Was This Post Helpful? 0
  • +
  • -

#15 poncho4all  Icon User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,405
  • Joined: 15-July 09

Re: Need help with pseudocode and what to enter in c++

Posted 27 September 2009 - 12:42 PM

The if condition goes like this
if (condition){
//do this
}
else
//do this
 


Here you are not doing that
  else ((humanScore < houseScore) && (houseScore <=21)){
		cout << "You Lose!";
	cout << humanScore << houseScore << endl;
	}



Either add another if or take out the condition ;)

Also you are missing a bracket here
void determineWinner(int humanScore, int houseScore) {
														//Compare the scores to see who won
	if ((humanScore > houseScore) && (humanScore <= 21)){
		cout << "You Win!";
	cout << humanScore << houseScore << endl;
	}
	if (humanScore == houseScore){
		cout << "Tie You Both Win!";
	cout << humanScore << houseScore << endl;
	}
	else ((humanScore < houseScore) && (houseScore <=21)){
		cout << "You Lose!";
	cout << humanScore << houseScore << endl;
	}
}//this bracket is not in your code



This is flooded with erros
void hit(int &playerScore){


char hit = 'y'||'n';
// Begin while loop
while (char hit == y){
if (humanScore <= 21) {		 //player has not busted
cout << "Do you want to take a hit?";
}
if (char hit == y){					 //player wants hit
cout << humanScore + dealCard() // adds humanScore to dealCard()
else{										   //players does not want hit
cout << "You decide to stand";
if (humanScore > 21){					//player has busted
cout << "You have gone over 21, You Lose";
}   //end if
}  //end else
} // end while


}
}


missing semicolons, redefinition of hit. Once you have declared it you dont need to declare it again in every condition. The declaration of hit should only be one value without the OR.

Hope that helps ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1