Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using arrays in JAVA and nothing more advanced, no nodes, no objects, no arrayli

ID: 3832219 • Letter: U

Question

Using arrays in JAVA and nothing more advanced, no nodes, no objects, no arraylist

(Simulation: coupon collector’s problem) Coupon collector is a classic statistics problem with many practical applications. The problem is to pick objects from a set of objects repeatedly and find out how many picks are needed for all the objects to be picked at least once. A variation of the problem is to pick cards from a shuffled deck of 52 cards repeatedly and find out how many picks are needed before you see one of each suit. Assume a picked card is placed back in the deck before picking another. Write a program to simulate the number of picks needed to get four cards from each suit and display the four cards picked (it is possible a card may be picked twice).

Here is a sample run of the program:
Queen of Spades

5 of Clubs

Queen of Hearts

4 of Diamonds

Number of picks: 12

Explanation / Answer

Given below is a Java program (CouponCollector.java) for coupon collector's problem using arrays as required. Comments are added in code for readability. Sample program output is also provided for reference.

File: CouponCollector.java

Sample Execution Output:

Seven of Hearts
Ten of Clubs
Two of Spades
Three of Clubs
Three of Diamonds
Number of picks: 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote