Java game Pontoon

Java game Pontoon

Hello. I have trouble with my pontoon code. I ahve done it using simple java programming. It is working BUT it dosent stops when the players hand rises ober 24 points. where in game the player should be bust it keeps asking do u want another card? i have used the if statement but it dosent seem to notice it. anyways here is my code. i just need ur little help if you could show me where the changes need to be made and how it would be really great.

import java.util.Scanner;

public class Pontoon{

 public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int playerScore = 0, computerScore = 0;
    String newCard = "";
    playerScore += dealCard();
    computerScore += dealCard();
    playerScore += dealCard();
    computerScore += dealCard();

    System.out.printf("Your score is %d would you like another card ? y/n ", playerScore);
    newCard = input.nextLine();
    if(newCard.equalsIgnoreCase("Y")) {
        while (newCard.equalsIgnoreCase("Y")) {
            playerScore += dealCard();
            System.out.printf("Your score is %d would you like another card ? y/n ", playerScore);
            newCard = input.nextLine();
        }
    }
    while(computerScore < 15){
        computerScore += dealCard();
    }
    checkWin(playerScore, computerScore);
}
public static int dealCard(){
    int value = (int) (Math.random() * 13) + 1;
    int score = 0;
    if(value == 1) {
        System.out.println("Ace!");
        score = 11;
    }else if (value == 13) {
        System.out.println("King!");
        score = 10;
    }else if (value == 12) {
        System.out.println("Queen!");
        score = 10;
    } else if (value == 11) {
        System.out.println("Jack!");
        score = 10;
    } else {
        score = value;
    }

    return score;
}

public static void checkWin(int Player, int Computer) {
    int player = Player;
    int computer = Computer;

    if (player > 21) {
        System.out.println("Player Bust");
    } else if (computer > 21) {
        System.out.println("Computer Bust");
    } else {
        if (player > computer) {
            System.out.println("Player Wins!");
        } else {
            System.out.println("Computer Wins!");
        }
    }
}

}

View Answers









Related Tutorials/Questions & Answers:
Java Game Pontoon
Java Game Pontoon  Could someone help me create a programme for the game pontoon //play a game of pontoon import java.util.*; public class Pontoon { public static void main (String args[]) { //deal initial hands
Java game Pontoon
Java game Pontoon  Hello. I have trouble with my pontoon code. I ahve done it using simple java programming. It is working BUT it dosent stops when the players hand rises ober 24 points. where in game the player should be bust
Advertisements
JAVA PONTOON
JAVA PONTOON  when this code is run it just continues. It needs to stop at 21 Or then say bust. Is someone able to help PLEASE :-) import java.util.Scanner; public class Pontoon{ public static void main(String[] args
Pontoon
Pontoon  I have this code.. To play a game of Pontoon (Blackjack) i want to be able to reach the number of 21 and then stop. This does... for no. import java.util.Scanner; public class Pontoon { public static void main
java game
java game  Can anyone please give me a game source code
JAVA Game
JAVA Game  I want to make a JAVA game...in dat game...d player has to input a word in 10 secnds...4 dat m running a delay loop... but the problem is not...i am not getting any way...to make that input field(eg: String str
Game
Game  How to develop a game using java? give me a total code for any simple game
game
game  How to make 3D game in java Applet
ModuleNotFoundError: No module named 'pontoon'
ModuleNotFoundError: No module named 'pontoon'  Hi, My Python... 'pontoon' How to remove the ModuleNotFoundError: No module named 'pontoon... to install padas library. You can install pontoon python with following command
ModuleNotFoundError: No module named 'pontoon'
ModuleNotFoundError: No module named 'pontoon'  Hi, My Python... 'pontoon' How to remove the ModuleNotFoundError: No module named 'pontoon... to install padas library. You can install pontoon python with following command
Game
Game  how can create simple game in java . thank u so match ,please help
game Nim - Java Beginners
game Nim  how is the search tree for a game Nim looks like
game
game  Hi thank you for answers.I am devoloping a java game caled Duck Hunt Game in netbeans6.7.1 software and I need help in some codes...,if you have this game's code please post me as soon as possible
Create a Swamp Game in Java
Create a Swamp Game in Java  You are to create a game called â??Get Out of My Swampâ??. In this game an ogre, called â??Hekâ??, wanders around his... two ogre enemies in the same place they kill the ogre and the game ends. Full
Java program for connectfour game
Java program for connectfour game  Hello, my program is about connectFour game. I need help with resolving the logic for this problem. I appreciate...; ConnectFourServer game = new ConnectFourServer(); private ConnectFourClient
Craps Game Java Programming Help
Craps Game Java Programming Help  Craps is a casino game that involves the throwing of a pair of dice. Based on the throw, the thrower either gets to continue throw (and win money), or stops throwing (and loses money). Write your
ModuleNotFoundError: No module named 'wagtail-localize-pontoon'
ModuleNotFoundError: No module named 'wagtail-localize-pontoon'  Hi...: No module named 'wagtail-localize-pontoon' How to remove the ModuleNotFoundError: No module named 'wagtail-localize-pontoon' error? Thanks  
who know full coding of guessing game in java?
who know full coding of guessing game in java?  There is only 1 player. Use JAVA Random toolkit to generate random number between 1 to 10. Once user... again or to exit the game by type 1 to proceed the game and type 2 to end the game
Java game bulls and cows
Java game bulls and cows In this tutorial, you will learn how to implement bulls and cows game in java. The game bulls and cows is an ancient game...;quit", the user will come out from the game. If the user inputs 4 digit
BRICK-BREAKER game concept - Java Beginners
BRICK-BREAKER game concept  I am planning to write a program for BRICK-BREAKER GAME. can any 1 help me any 1 can u plz help me frzzz?? you can also send the mails to [email protected]
genaral snake game in java - Java Beginners
genaral snake game in java  can u please send code for fallowing write a snake game program using swings?  Hi This is the source code of Snake game in swing Snake.java file import javax.swing.JFrame
tetris game code - Swing AWT
tetris game code  To develop a JAVA puzzle game which is a "variation" of the Tetris game
game programming
game programming  Hi. i have witten the script and have almost completed developing a social game like mafia wars. can any one plz help me by answering me some of my doubts.. after uploading the game on facebook how tokeep data
Maven dependency for com.cjmalloy - gwt-game-ui version 1.1 is released. Learn to use gwt-game-ui version 1.1 in Maven based Java projects
this version ( com.cjmalloy - gwt-game-ui version 1.1 ) in their Java project... 1.1 in project? Steps to use  com.cjmalloy - gwt-game-ui version 1.1 in Java...; com.cjmalloy - gwt-game-ui version 1.1 java library in your project. ADS
Blackjack game - IDE Questions
Blackjack game  Create a java code for a simple blackjack game for just one hand of Blackjack, it does not need to include money and betting
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.0.6 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.0.6 in Maven based Java projects
-game-servers-v1 version 1.0.6 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.1.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.1.0 in Maven based Java projects
-game-servers-v1 version 1.1.0 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.1.1 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.1.1 in Maven based Java projects
-game-servers-v1 version 1.1.1 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.1.3 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.1.3 in Maven based Java projects
-game-servers-v1 version 1.1.3 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.2.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.2.0 in Maven based Java projects
-game-servers-v1 version 1.2.0 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.2.2 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.2.2 in Maven based Java projects
-game-servers-v1 version 1.2.2 java library in your project. Now you can save...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.10 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.10 in Maven based Java projects
- proto-google-cloud-game-servers-v1 version 2.1.10 java library in your project...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.9 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.9 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.9 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.7 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.7 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.7 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.7.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.7.0 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.7.0 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.6.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.6.0 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.6.0 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 1.0.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 1.0.0 in Maven based Java projects
-google-cloud-game-servers-v1 version 1.0.0 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.8 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.8 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.8 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.5 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.5 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.5 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.4 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.4 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.4 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.3.2 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.3.2 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.3.2 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.3.5 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.3.5 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.3.5 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.3.4 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.3.4 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.3.4 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.3.3 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.3.3 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.3.3 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.4.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.4.0 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.4.0 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.2 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.2 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.2 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.1 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.1 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.1 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.1.0 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.1.0 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.1.0 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.2.1 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.2.1 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.2.1 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest
Maven dependency for com.google.api.grpc - proto-google-cloud-game-servers-v1 version 2.0.3 is released. Learn to use proto-google-cloud-game-servers-v1 version 2.0.3 in Maven based Java projects
-google-cloud-game-servers-v1 version 2.0.3 java library in your project. ADS...-google-cloud-game-servers-v1 released The developers of   com.google.api.grpc - proto-google-cloud-game-servers-v1 project have released the latest

Ads