Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following algorithm represents a Black Jack player who requests additional cards, while cards are still available, until they either hit 21 or go bust.

The following algorithm represents a Black Jack player who requests additional cards, while cards are still available, until they either hit 21 or go bust. Which is the correct continuation condition for the while loop?

final Scanner input = new Scanner(System.in); final int MAX = 21; int sum = 0; while (/* TODO your choice below */) { final int cardValue = input.nextInt(); sum += cardValue; } if (sum == MAX) { System.out.println("Black Jack"); } else { System.out.println("bust"); }

  • A.

    input.hasNextInt() || sum < MAX

  • B.

    sum <= MAX

  • C.

    input.hasNextInt() && sum < MAX

  • D.

    input.hasNextInt()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago