Write a Java program that will use while loops. The while loop will show the cards currently in the hand and ask the user to accept a card (Hit) or to stop (Stand). Within the while loop the program should print the card that was just added, all the cards in the hand, and the new value of the hand. If the value of the hand exceeds 21, the game should end (the while loop should stop). Write out the algorithm for the while loop. Turn in a printout of the algorithm, the code and a printout of a sample run. Place the algorithm and the sample run inside comment blocks in the code. "The sample runs of such a program are on the attached image."
Write a Java program that will use while loops. The while loop will show the cards currently in the hand and ask the user to accept a card (Hit) or to stop (Stand). Within the while loop the program should print the card that was just added, all the cards in the hand, and the new value of the hand. If the value of the hand exceeds 21, the game should end (the while loop should stop).
Write out the
![Starting with an empty hand
Do you wish to hit or stand (h/s)? h
Your card: Jack of DIAMONDS
Hand after drawing card:
[Jack of DIAMONDS]
Hand value: 10
Do you wish to hit or stand (h/s)? h
Your card: Ten of DIAMONDS
Hand after drawing card:
[Jack of DIAMONDS, Ten of DIAMONDS]
Hand value: 20
Do you wish to hit or stand (h/s)? s
Starting with an empty hand
Do you wish to hit or stand (h/s)? h
Your card: King of HEARTS
Hand after drawing card:
[King of HEARTS]
Hand value: 10
Do you wish to hit or stand (h/s)? h
Your card: Seven of DIAMONDS
Hand after drawing card:
[King of HEARTS, Seven of DIAMONDS]
Hand value: 17
Do you wish to hit or stand (h/s)? h
Your card: Five of CLUBS
Hand after drawing card:
[King of HEARTS, Seven of DIAMONDS, Five of CLUBS]
Hand value: 22
Sorry you busted](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F8f295989-0e6d-45c2-9ab7-cdca523774a7%2Fc473666c-6c5b-4121-b693-5b7d1f968608%2F4zzw4ob_processed.png&w=3840&q=75)

The while loop in Java is used to execute a specific code until a certain condition is met. The syntax of the while loop is:
while (testExpression) {
// loop content
}
Here,
The while loop evaluates the textExpression inside the parentheses ().
If textExpression evaluates to true, then the code inside the while loop is executed.
TextExpression is reevaluated.
This process continues until textExpression is false. When textExpression evaluates to false, the loop will stop .
Step by step
Solved in 2 steps









