Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,053 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,574 people online right now. Registration is fast and FREE... Join Now!




My code still has errors

 
Reply to this topicStart new topic

My code still has errors, C++ Blackjack code still has errors. Help

izm94303
3 Aug, 2008 - 05:12 PM
Post #1

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 21


My Contributions
Thanks everyone for the help.

This post has been edited by izm94303: 3 Aug, 2008 - 05:15 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: My Code Still Has Errors
3 Aug, 2008 - 05:16 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 212 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
1) Please post in the correct forum. Introduce yourself is for actually introducing yourself not programming questions. *Moved*

2) Show us the 13 errors you are getting.

3) Putting things like ASAP, SOS etc isn't going to get things done any faster. We are pretty quick as long as you remember to post all the info you can on the problem.

Thanks for helping us help you! smile.gif

This post has been edited by Martyr2: 3 Aug, 2008 - 05:16 PM
User is online!Profile CardPM
+Quote Post

izm94303
RE: My Code Still Has Errors
3 Aug, 2008 - 05:19 PM
Post #3

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 21


My Contributions
CODE


#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 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) {

// Chooses winner
if ((houseScore > humanScore) && (houseScore >= 21) && (humanScore < houseScore)) { //Gets computers score
     cout << "Computer Wins ";
if  ((humanScore > houseScore) && (humanScore >= 21) && (houseScore < humanScore))  //Gets user score
         cout << "You Win ";
    else if ((houseScore == humanScore) && (humanScore == houseScore));
             cout << ("Tie Game ")<< endl;
             //end ifs
             //end function
             return;
}
// Deals the cards
int dealCards = int numberOfCards, string message;{ [error:type'int'unexpected]
int ret_val = (0, val);  [error:'val'undeclared identifier]
int cards = numberOfCards;  [error:'numberOfCards'undeclared identifier]
int numberOfCards = 0;
int val = 0;

cout << message;  [error:'message':undeclared identifier]
while(cards--){  
// Values from 1 to K  
val = Random(0,14);  
if( val > 10 ) val = 10;  
     if( val == 1 ) val = 11;  
     cout << val;  
        if(cards)  
        cout << ",";  
        ret_val+=val;  
}
return;
}

//Want a hit?
void hit(int &playerScore){ [error:'hit':localfunctiondefinitions are illegal]
int playerScore = val;
int playerScore = 0.0;
char hit = ' ';
double = choice;
cout << "Do you want a hit (y/n)?";
cin >> ' ';
     }do while (hit == 'Y' || hit == 'y'); [error:noconversionfrom'int'to'void'(cdecl*)(int&)]
         person += dealCards(1); // Deals one card [error:syntax error:identifier'person']
           if ((playerScore < 21)); [error:undeclared identifier]
        cout << val;  // Displays score
        cout << "Do you want another hit (y/n)?";
        cin >> endl;
              do while (playerScore < 21) ||  (hit !='n');
                    if ((playerScore > 21);
                     cout << val << "Busted" << endl;
                     //end while
                     //end ifs
                     //end function
}
return ret_val;

}

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


I've been working on this since 3 a.m. I have narrowed it down from 34 errors to 13 can someone please explain the errors to me. I truely don't understand.

This post has been edited by izm94303: 3 Aug, 2008 - 05:22 PM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: My Code Still Has Errors
3 Aug, 2008 - 05:21 PM
Post #4

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 212 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Please do no repost questions that you already asked and then erased two minutes ago. Topics have been merged.

smile.gif
User is online!Profile CardPM
+Quote Post

izm94303
RE: My Code Still Has Errors
3 Aug, 2008 - 05:25 PM
Post #5

New D.I.C Head
*

Joined: 1 Aug, 2008
Posts: 21


My Contributions
QUOTE(Martyr2 @ 3 Aug, 2008 - 06:21 PM) *

Please do no repost questions that you already asked and then erased two minutes ago. Topics have been merged.

smile.gif



Sorry. Again, this is my first shot at forums. I forgot the code tags. I didn't want to piss anyone else off by not including them. Bare with me, I will get this site down pat.
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: My Code Still Has Errors
3 Aug, 2008 - 05:31 PM
Post #6

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 212 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
QUOTE(izm94303 @ 3 Aug, 2008 - 06:25 PM) *

QUOTE(Martyr2 @ 3 Aug, 2008 - 06:21 PM) *

Please do no repost questions that you already asked and then erased two minutes ago. Topics have been merged.

smile.gif



Sorry. Again, this is my first shot at forums. I forgot the code tags. I didn't want to piss anyone else off by not including them. Bare with me, I will get this site down pat.


Its fine if you forget the code tags on your first few posts, we tend to add them and a small warning, just remember to add them in the future. I do appreciate that you at least are trying to add code tags. Makes our job easier.

Now if you can show us your 13 errors we can help you out. smile.gif
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 05:46PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month