Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

overall Assignment For this assignment, you are to write a simple computer program which will use arrays to create a deck of cards, shuffle the

image text in transcribed
image text in transcribed
image text in transcribed
overall Assignment For this assignment, you are to write a simple computer program which will use arrays to create a deck of cards, shuffle the deck, deal some hands, and print out the dealt hands. Possible optional enhancements include classifying the hands in a manner similar to a recent lab exercise. Representing Playing Cards Standard playing cards can be easily represented using two integers: One ranging from 0 to 12 for the ranks (numbers)ofthe cards ranging from deuce (2) to ace, and one ranging from 0 to 3 representing the 4 suits, as shown in the following tables: Suit Value Represents Rank value Represents Clubs rank 2 0 to 8 Diamonds Jack Hearts 10 Queen Spades King 12 Ace Creating an ordered Deck of Cards The best way to create a shuffled deck of cards to first create an ordered deck of cards, and then shuffle it. This approach guarantees that every card is represented exactly on with no missing cards duplicates, and it does so in a reasonable time. and "ranks", each Key to or arrays, named suits" storing the deck of cards will be two containing room for 52 integers. Each card in the deck will be represented by matching entries in the two arrays. For example, the 10th card in the deck will have a suit according to the 10th element in the suits[ array, and a rank number according to the 10th element in the ranks[Jarray. "i"), that varies from 0 to 51 inclusive To fill the arrays, create a loop with an integer, say o In the suitsl Jarray for position i, store i%4. Convince yourselfthat this will generate the series 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, sets of the sequence 0, 1,2, 3. o In the ranks[ Jarray for position i, store i/4. Convince yourself that this will generate the series 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 12, 12, e. 13 sets of 4 matching integers The resulting deck should look like this: Rank 0 0 0 1 1 1 12 12 12 12 Card 2 C 2 D 2 H 2 C 3 D 3 H 3 ST. AC AD AHAS S 3

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

1. What might have led to the misinformation?

Answered: 1 week ago

Question

2. How will you handle the situation?

Answered: 1 week ago