Perhaps a little bit of help with my comp sci hmwk?

Mik3y

Banned
Mar 2, 2004
7,089
0
0
Hey guys. i'm in an intro to comp sci class and i cant happen to get this program set up properly. my assignment is the first one from www.cs1a.com. I'm using dev C++ and this is what i have so far:

#include<iostream>
#include<stdlib.h>
using namespace std;

// This program was created by Mike Tran.

// This program simulates the game of Blackjack.

int main(void)
{
// Variable List
float playerCard1;
float dealerCard;
float playerCard2;

cout << "Enter a number between 1 and 13: ";
cin >> playerCard1;

cout << "Enter another number between 1 and 13: ";
cin >> playerCard2;

cout << "Enter one more number between 1 and 13: ";
cin >> playerCard3;

if (playerCard==1)
{

system ("pause");
}

it's not much yet, but i'm not sure how to set up the if statements in this case. we've done them before, but none this complicated to our standards. if you guys can help me, that'd be great. :)
 

mugs

Lifer
Apr 29, 2003
48,920
46
91
why are you using floats to store integers?

That problem is pretty easy when you consider the hint the prof gave you.
 

raystorm

Diamond Member
Apr 24, 2001
4,712
2
0
Originally posted by: mugs
why are you using floats to store integers?

He also has a "playercard3" instead of dealercard. Unless thats supposed to be there and he didn't declare it.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: raystorm
Originally posted by: mugs
why are you using floats to store integers?

He also has a "playercard3" instead of dealercard. Unless thats supposed to be there and he didn't declare it.

And...

if (playerCard==1)
{

system ("pause");
}


playerCard is undefined also
 

JetBlack69

Diamond Member
Sep 16, 2001
4,580
1
0
how do you know if a player entered a number between 1 and 13? what if he entered 14?
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
From his hmwk website:


Write a blackjack program...
Request three numbers (between 1 and 13) from the user.
Call the first number playerCard1
Call the second number dealerCard
Call the third number playerCard2

Here are the rules I want you to follow...

if the two players cards are 1, output split, otherwise
if the two players cards are 8, output split, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 12 or more, output Stay, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 10 or 11, output Double, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 3 - 9, output hit, otherwise
if the dealers card is a 7 to 11 and the players cards add up to less then 16, output hit, otherwise
if the dealers card is a 7 to 11 and the players cards add up to 17 or more, output stay, otherwise
if the dealers card is a 1, output Insurance.


That's not how I learned how to play blackjack.
 

EmperorIQ

Platinum Member
Sep 30, 2003
2,003
0
0
Originally posted by: TuxDave
From his hmwk website:


Write a blackjack program...
Request three numbers (between 1 and 13) from the user.
Call the first number playerCard1
Call the second number dealerCard
Call the third number playerCard2

Here are the rules I want you to follow...

if the two players cards are 1, output split, otherwise
if the two players cards are 8, output split, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 12 or more, output Stay, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 10 or 11, output Double, otherwise
if the dealers card is a 2, 3, 4, 5, or 6, and the players cards add up to 3 - 9, output hit, otherwise
if the dealers card is a 7 to 11 and the players cards add up to less then 16, output hit, otherwise
if the dealers card is a 7 to 11 and the players cards add up to 17 or more, output stay, otherwise
if the dealers card is a 1, output Insurance.


That's not how I learned how to play blackjack.
that's like the code dude. I wish my CS professors gave it this easy.