******IN JAVA*****
Your objective is to beat the dealer's hand without going over 21. Cards dealt (randomly) are between 1 and 11. You receive 2 cards, are shown the total, and then are asked (in a loop) whether you want another card. You can request as many cards as you like, one at a time, but don't go over 21. (If you go over 21 it should not allow you any more cards and you lose) Determine the dealer's hand by generating a random number between 1 and 11 and adding 10 to it. Compare your hand with the dealer's hand and indicate who wins (dealer wins a draw)
SOLUTION-
I have solve the problem in Java code with comments and screenshot
for easy understanding :)
CODE-
//java code
import java.util.*;
//main class
public class Main {
//main method
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String answer = "";
int you = 0;
System.out.println("Your Score " + you); //show score
int dealer = getRandomNumber(1, 11) + 10; //dealer
calcualtion
while (true) //loop until it get false
{
System.out.print("Do you want another card? (y / n) "); //ask for
user to play y or n
answer = scanner.nextLine(); //reads
if (answer.equals("y")) //if yes (y)
{
int num = getRandomNumber(1, 11); //call random function and give
random number
you+=num;
if (you <= 21) //if number is less than 21
{
System.out.println("Your Score " + you); //print score
}
else //else part
{
System.out.println("Your Score " + you);
System.out.println("Your Score reached more than 21");
System.out.println("Sorry! You lost the game");
break;
}
}
else //show result who won or draw
{
if (you > dealer)
{
System.out.println("You won the game, "+ "You - " +you+ " Dealer -
"+dealer);
}
else if(you == dealer)
{
System.out.println("Draw, "+ "You - " +you+ " Dealer -
"+dealer);
}
else
{
System.out.println("Dealer won the game, "+ "You - " +you+ " Dealer
- "+dealer);
}
break;
}
}
}
//function getRandomNumber
static int getRandomNumber(int min, int max)
{
return (int) ((Math.random() * (max - min)) + min);
}
}
SCREENSHOT-



IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL
SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------
******IN JAVA***** Your objective is to beat the dealer's hand without going over 21. Cards dealt...
Create a simplified Blackjack game using the Deck and Card classes (download the attached files to start). There is also a "TestCard" class that creates a Deck and runs some simple code. You may choose to use this file to help you get started with your game program. 1) Deal 2 cards to the "player" and 2 cards to the "dealer". Print both the player's cards, print one of the dealer's cards. Print the total value of the player's hand. 2) Ask...
Must be in C++ Question: Blackjack (twenty-one) is a casino game played with cards. The goal of the game to draw cards that total as close to 21 points as possible without going over. All face cards count as 10 points, aces count as 1 or 11, and all other cards count their numeric value. The game is played against a dealer. The player tries to get closer to 21 (without going over) than the dealer. If the dealer busts...
"Blackjack 40" my teacher created this assignment and I need help. He is using c++ and has provided this template: Further instructions are below the template! #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //Will return a number from 1 to 13, representing the face of a card int draw_card() { return rand() % 13 + 1; } int main() { const int BET = 10; //This will allow you to control chance, to make testing easier cout <<...
programming language c++
its a project if anyone can help me it's will be
appreciated thnk u.
u have to create a code based on the information im giving
u
you can do it in 1 or 2 day i can wait
1:26 #WW 2.53% Example: A user starts with 1000 points. Game #1 - user chooses to risk 200 points. User wins game (beats the dealer). User now has 1200 points. Game #2 - user chooses to risk 500...
programming language c++
programming language c++
1:25 #WW # 53% You may, if you wish, work in pairs; this means that a submission may have 2 names attached but those 2 people must have worked on the project. No free rides! The way to submit the program to me is as follows: put the entire program (main and any other functions) into a single compile. Compile it to be sure that you have the correct set of #include statements and...
Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...
You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. You may complete this project individually or in a group of no more than 2 other people. Requirements do not change if you choose to complete the project individually or as part of a group. Customer-specific requirements You can create...
MATLAB code help!
Function Name: jackSparrow Inputs: 1. (double) A 1x2 vector describing your hand 2. (double) A 1x2 vector describing Jack Sparrow's hand 3. (double) A vector with the next cards to be drawn from the deck Outputs: 1. (char) A description of the game outcome Background: You're out at sea with the infamous Jack Sparrow, and it's a pretty calm day. Without anything better to do, Jack Sparrow challenges you to his favorite card game: BlackJack (Sparrow edition)...
Note: Please write the Pseudocode using Arrays method in Java language. Program 2 (40%); For this assignment, we're going to make a game. Imagine you initially start with a random "hand" of two cards (values 2-9). Your goal is to continue to add to your hand until the sum of the cards is between 21 25, at which point youu win. Further, if you hold 5 cards, you win. However, if you exceed a sum of 25, you lose. Admittedly,...
Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...