Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!