Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that picks four cards from a deck of 52 cards and compute their sum. An Ace, King, Queen, Jack represent 1,13,12,11, respectively.

Write a program that picks four cards from a deck of 52 cards and compute their sum. An Ace, King, Queen, Jack represent 1,13,12,11, respectively. Your program needs to ask the user for the sum, find the number of the total combinations, the number of the combinations that yields the sum, and the list of all the combinations that yields the sum.

This is the Shell:

image text in transcribed

Sample Output:

image text in transcribed

Header Header Header import java.util.scanner public class Cards i Main method, do not add anything public static void main [String[] args) { scanner kb-new Scanner(Systen.in?; sum (xb) Initialize the deck then loop while the user wants to continue: ask for a sum using the validation method loop chrough every possible selection of 4 carda / if the sun of the 4 chose eqals the sun desired then update your counter and output ccmbination update the counter for the total number of combinations Initialize Variables including deck of cards) Loop while player wishes to continue public static void sun(Scanner kb) // Use the validation method to prompt for the aum Locp through possible combinations (nt: Use 4 nested fcr Locps) sum matches then update the counter and output combination Update total combination counter Output final results and prompt to continue / If they do not want to continue the set the boolean variable for continuing to false Prompt the user to input the sum of combinations desired. Use the / co ensure that they are entering a number. Also, continue to 1cop / a positive number haaNextint) method until they have entered public atatic int datavalidation (Scanner kb) return ?; // remove 0 and put your variable for the valid inp. Create and return a 1-dinenaional array for all 52 cards. Note that you can don thia in one line using the quick" initialization ayntax f for arrays. Also, do not worry about the suits, just add the numbers to the array // This means that an Ace of Hearts ?? the same a an ? ce of Spaces they are both 1 so you will have 4 of each number in the array public static int[) initialize return nulli remove "null" and put your new array variable instead

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

Let {N(t), t 0} be a Poisson process with rate . For i n and s

Answered: 1 week ago

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago