hello

alright, i made a blackjack program, it works. i don't know what i would do for the face cards, like jack,king,queen,and ace, how would i put them into a random generator. the jack,king,queen count as 10. also how would i get the ace to count as either 11 or 1, when needed.

i know the indentation is off, but its better than other programs that i have made.

also any hints if i could put more into a loop or something.

thanks

Code:#include<iostream> #include <cstdlib> //to use rand function #include <ctime> // to use time as the seed for rand using namespace std; /* Randall Foor Blackjack program 9/30/10 */ int main(){ for(int x=10;x>0;x--) { int guess, number,numcards, cardnum; int cardnumber; int n1,n2,n3,n4,n5; int numberGuesses; int total; char anothercard,repeat; srand(time(0)); /* while (numberGuesses < 10) { number = 1 + rand() % 10; cout << number << endl; numberGuesses++; } */ for (int n=2; n>0; n--) //outputs random numbers for cards { numberGuesses = 1; number = 1 + rand() % 10; cout <<"card with the value of: "<< number<<","<<endl; } cout<<"how many cards do you have? \n"; //asks how many cards you got cin>>cardnum; cout<<"what is the card value? \n"; //asks what the number of the card was cin>>n1>>n2; //stores card value total=n1+n2; //computes total if(total==21) { cout<<"you win!! \n"; } if(total>=22) { cout<<"busted \n"; } if(total<=20) { cout<<"your total is "<<total<<" \n"; cout<<"would you like another card? <Y or N>:"; cin>>anothercard; if(anothercard=='y' || anothercard=='Y') //if you want another card { for(int nextcard=3; nextcard>0;nextcard++) //enters loop to get card number { numberGuesses = 1; number = 1 + rand() % 10; //makes random number for card cout <<nextcard<<" cards \n"; cout<<" card value of : "<< number<<endl; cout<<"what was the card value? "; if(nextcard==3) { cin>>n3; total=n1+n2+n3; cout<<"total value of cards "<<total<<endl; if(total==21) { cout<<"you win!!! \n"; } if(total>=22) { cout<<"busted \n"; } } if(nextcard==4) { cin>>n4; total=n1+n2+n3+n4; cout<<"total value of cards "<<total<<endl; if(total==21) { cout<<"you win!!! \n"; } if(total>=22) { cout<<"busted \n"; } } if(nextcard==5) { cin>>n5; total=n1+n2+n3+n4+n5; cout<<"total value of cards "<<total<<endl; if(total==21) { cout<<"you win!!! \n"; } if(total>=22) { cout<<"busted \n"; } } if(nextcard==5 || total>=21) { break; //breaks loop after cout<<"you lose \n"; } } } } cout<<"Do you want to repeat? <Y or N> \n"; cin>>repeat; if(repeat=='y' || repeat=='Y') { //breaks loop system("cls"); } if(repeat=='n' || repeat=='N'){ //breaks loop system("cls"); break; } } system("pause"); return 0; }