V22.0005 - Spring 2003
Assignment # 1

Due: Tuesday, Feb. 4th


This is a simple programming assignment involving arrays. It may be programmed in any language of your choice: Pascal, C, Java, Ada, etc., etc. It may also be run on any platform of your choice: Mac, Windows, UNIX, etc. There are many compilers available at the University, and you are probably familiar with one or more.

Turn in you assignment by emailing it to the grader at pnp2@cs.nyu.edu

Basically, you are to set up an array which is thirteen postions long, which will represent the ranks of a suit of cards: That is the cards Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. Using a random number generator, pick 100 cards at random, printing out the results as you go along and counting which card you have drawn in the array. (Note that the rank is a random number 1-13, and the suit is a separate random number 1 - 4.) Once you have picked all 100 cards, print out how many of each rank the computer chose. Finally, print out what the HIGHEST count was, and which rank or ranks received that count. Also, print out the number of RED cards (hearts and diamonds) and the number of BLACK cards (spades and clubs).

A portion of the output might look like:

Here are your cards: Card # 1 = Ace of Spades
Card # 2 = 10 of Hearts
Card # 3 = 9 of Hearts
Card # 4 = King of Clubs
Card # 5 = 9 of Diamonds Card # 6 = Ace of Spades
Card # 99 = Ace
Card # 100 = 7
You were dealt an Ace 7 times. You were dealt a 2 card 9 times. . . You were dealt a King 9 times. The highest count was 9, and was found on a 2 card and King. You were dealt 52 red cards and 48 black cards.