I'm programming Blackjack and all is well, except after I type 'y' to hit again, the program terminates even though total is still less then 21. So my while statement is doing nothing? package com.github.geodox.blackjack; import java.util.Random; import java.util.Scanner; public class Blackjack { private static int total = 0; private static Random rand = new Random(); private static Scanner scan = new Scanner(System.in); public static void main(String[] args) { int card1 = rand.nextInt(11)+1; System.out.println(card1); int card2 = rand.nextInt(11)+1; System.out.println(card2); if(card1 == 11 & card2 == 11) total = 12; else total = card1 + card2; System.out.println(total); while(total < 21) { …

Member Avatar
Member Avatar
+0 forum 4

The below program is working but it have some constraint #include<windows.h> #include<iostream> using namespace std; void gotoxy(int x,int y) { COORD CursorPosition; CursorPosition.X=x; CursorPosition.Y=y; SetConsoleCursorPosition((GetStdHandle(STD_OUTPUT_HANDLE)),CursorPosition); } void decone(int num,char suit,int x,int y) { int i; for(i=0;i<200000000;i++); gotoxy(x,y); for(i=0;i<11;i++) { cout<<"*"; } y++; gotoxy(x,y); cout<<"*"; gotoxy(x+10,y); cout<<"*"; y++; gotoxy(x,y); cout<<"* "<<suit; gotoxy(x+7,y); cout<<suit<<" *"; y++; gotoxy(x,y); cout<<"*"; gotoxy(x+10,y); cout<<"*"; y++; gotoxy(x,y); cout<<"*"; if(num==11) { gotoxy(x+5,y); cout<<"J"; } else if(num==12) { gotoxy(x+5,y); cout<<"Q"; } else if(num==0) { gotoxy(x+5,y); cout<<"K"; } else if(num==1) { gotoxy(x+5,y); cout<<"A"; } else if(num>1 && num<11) { gotoxy(x+5,y); cout<<num; } gotoxy(x+10,y); cout<<"*"; y++; gotoxy(x,y); cout<<"*"; gotoxy(x+10,y); cout<<"*"; y++; …

Member Avatar
Member Avatar
+0 forum 1

Option Explicit Dim card(1 To 52) As String Dim cardused(1 To 52) As String Dim deck(1 To 52) As String Dim profit As Integer Dim playerscore(1 To 5) As Integer, dealerscore(1 To 5) As Integer Dim playercards As Integer, dealercards As Integer Dim currentcard As Integer Dim playerscard(1 To 6) As String, dealerscard(1 To 6) As String Dim playercount As Integer, dealercount As Integer Dim random As Integer Dim aces As Integer Dim x As Integer Private Sub Form_Load() Randomize cmdDeal.Enabled = False For x = 1 To 13 card(x) = "Heart" & x Next x For x = 1 …

Member Avatar
Member Avatar
+0 forum 1

so basically the thing is nearly complete, and im just trying to get it to work, im pretty sure i just havent closed off some statments and such, but i cannot for the life of me see where, or how to get the error messages to leave me alone in peace if you could have a look over, tell me where it needs changing, that would be great and i will send you unicorn, thanks in advance. #include <iostream> #include <ctime> //For time generator void Cardshuffle(bool DealtCards[]); void PrintCard(int iCard); void PrintHand(int iaHand[], const int ConsDealtCard); int GetNextCard(bool DealtCards[]); int …

Member Avatar
Member Avatar
+0 forum 13

Hello, I am currently writing a card game in Java. My question is when I write the follwoing code below: `Inline Code Example Here` 38 // select a random number between 0 and 51 39 int second = randomNumbers.nextInt( NUMBER_OF_CARDS ); Will the program properly generate 52 cards? Should I be using ( NUMBER_OF_CARDS - 1) equals 52 real cards or would it properly generate the 52 cards the way I have it programmed? Thanks for all the assistance! Regards, J-Man

Member Avatar
Member Avatar
+0 forum 2

I am familiar with loops, functions, recursions, (though I have praticed some questions, it is troubling to get the hang of it completely), passing by value, reference and ofcourse pointers. I can work with arrays and 2d arrays. This is my second project. My first project was hangman. My sir wasn't impressed if he did approve of what I made. This time, I wish to do better. I am willing to work harder but this project marks means alot. I want to ask you, is blackjack a better option to make my c++ project or checkers? I prefer checkers but …

Member Avatar
Member Avatar
+0 forum 9

Hello, I am rather new to this so bare with me! I am currenlty creating a BlackJack game in Java and attempting to use the MVC design when creating it. I have so far created the following classes: - Card: To hold create a card - Deck: To create a deck filled with all 52 cards - Hand: To hold a 'Hand' of Cards - Player: To create a Player for game use - BlackJackTest: Here I am testing all the functions of the game trying to get something working! I have currently got to the point where I can …

Member Avatar
Member Avatar
+0 forum 4

I am making a simple blackjack game. I have now made the deck which i can draw cards from. But I don't know how to get the values from each card so that i can add them together. I have a card class named Kort with the enum: [CODE]public enum KortVerdi { To, Tre, Fire, Fem, Seks, Sju, Åtte, Ni, Ti, Knekt, Dame, Konge, Ess }; public enum KortFarge { Hjerter, Kløver, Ruter, Spar };[/CODE] And when i draw two cards with my draw method from my main i would like to get the values of the two cards so …

Member Avatar
Member Avatar
+0 forum 5

[CODE]#include <iostream> #include <ctime> #include <cstdlib> #include <string> using namespace std; int getCardPoints(int value, int & aceValue) { if ((value >= 2) && (value <= 10)) { return (value); } else if (value == 1) { aceValue = 10; // 11 -1 return 1; // Already contain 1 for the Ace value } else if (value == 11) { return 10; } else if (value == 12) { return 10; } else if (value == 13) { return 10; } else { cout << "Error! Invalid card value." << endl; exit (0); } } void displayCardFace(int face) { if ((face …

Member Avatar
Member Avatar
+0 forum 1

I have a Blackjack Assignment I need some help on. The Full requirements, what the .exe should look like, and what I have done so far is in this picasa link: [COLOR="Green"]https://picasaweb.google.com/zaidalmas/November172011?authuser=0&authkey=Gv1sRgCNXrltTFwZnYNQ&feat=directlink[/COLOR] Sorry I couldn't get the insert link to work right. What I have done: I have shuffled the cards and dealed 2 cards to each player besides the dealer. Problem: I need an array to hold the cards and an array to calculate the total It doesn't seem that tough but I was instructed to only use the switch(num) statement and shuffle code once in the program. Refer …

Member Avatar
Member Avatar
+0 forum 8

Im trying to change this modified blackjack game to where there is no computer. A choice of either two or three players is asked with three cards dealt instead. How can I i change this current code to 1) prompt user for either 2 or 3 players(no computer), 2) have a 2 or 3 player game that works. Any idea or input is welcomed, thanks! [ICODE] from random import choice as rc def total(hand): # how many aces in the hand aces = hand.count(11) # to complicate things a little the ace can be 11 or 1 # this little …

Member Avatar
Member Avatar
+0 forum 3

Hello all, I am working on a Blackjack program, but am having a bit of trouble with the finer details. At the moment, I have a list of the cards and their values, as follows: [CODE] Jack = 10 Queen = 10 King = 10 Ace = 11 # card list cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace] [/CODE] This allows the calculations later on in the program to do their bit, which is fine. However, at the moment I get this: [CODE] Dealer has [2, 10, 10] for a total of …

Member Avatar
Member Avatar
+0 forum 20

I'm having an issue with my program when I call the "drawCardFace" and "drawCardSuit" functions. The function calculates and gives one answer the first time I call it. And then uses that same answer the next 4 times I call it. Can someone explain what I need to do to fix that? I've tried just about everything I can come up with. Thank you! [CODE] #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; void drawCardFace (int & face) { srand ((unsigned)time(0)); face = (rand()%13)+1; } void drawCardSuit (int & suit) { suit = (rand()%4)+1; } void displayCardFace …

Member Avatar
Member Avatar
+0 forum 2

Im writing a blackjack program to train one to count cards using the Hi-Lo System. I found the engine online ( it was open sourced.) Instead of the code here using only numbers and Letters, i want to add only pictures of the cards instead of the numbers and card values. I need help. I recently downloaded pygame to help me import images. but i am having no luck.. Please take a look #!/usr/bin/python import Tkinter import sys import tkMessageBox from random import shuffle import pygame.image import pygame.display class cardTrainer: def __init__(self, master): #Define the deck of cards by list …

Member Avatar
+0 forum 0

[code] #include<iostream.h> #include<conio.h> #include<iomanip.h> #include<stdio.h> #include<stdlib.h> #include<fstream.h> #include<string.h> int n=0; // current no. of players ( to add to next one) int num=0; // total number of players class date { public: int dd; int mm; int yy; }; class players { public: char name[30]; date dob; char userid[30]; char pass[30]; char sec_q[30]; char sec_a[30]; float bet; float bal; int rounds_won; int tot_rounds; float win; void create_account(); void log_in(); void forgot_pass(); void delete_account(); void highscores(); void display_players(); }p[100]; void players::create_account() { fstream f; f.open("player_details.dat",ios::app|ios::out); char pass1[30],pass2[30],id[30]; cout<<"SIGN UP \n\n"<<endl; cout<<"PLAYER DETAILS\n "<<endl; cout<<"FULL NAME"<<endl;gets(p[n].name); cout<<"DOB (dd/mm/yy)"<<endl;cin>>p[n].dob.dd>>p[n].dob.mm>>p[n].dob.yy; A: { cout<<"SCREEN NAME"<<endl;gets(id); …

Member Avatar
Member Avatar
+0 forum 3

Hey, I'm a student with rudimentry knoledge of VB6 and I've a college project where I have to develop a blackjack game. Unfortuanately I've a problem with the method I call the cards I was wondering if any of you would be able to shed some light on the problem. [CODE]Option Explicit Private Sub Command1_Click() Dim card(5) As Integer Dim x As Integer Dim y As Integer Dim d As Integer Dim discard(5) As Integer x = 0 y = 0 d = x - 1 Randomize card(x) = Int((52 * Rnd) + 1) Debug.Assert (Val(card(x))) Do While (y < …

Member Avatar
Member Avatar
+0 forum 9

You can place the game "Blackjack" by adding the following script to your website. All the information is included within the script, please do not remove the warranty or information. If you don't want such a big lap of code on your website, you can also place the following, as this is a link to exactly the same script: [code] <script src="http://www.symbolwebdesign.nl/webapps/blackjack.js" type="text/javascript"></script> [/code] Have fun and good luck at playing Blackjack! [B]~G[/B]

Member Avatar
+0 forum 0

The End.