Question: Write an application that stores the values for a deck of 52 cards. Use an integer array to hold the values. You are storing the

Write an application that stores the values for a deck of 52 cards. Use an integer array to hold the values. You are storing the values 0 to 12, 13 to 25, 26 to 38, and 39 to 51 which represent 13 spades (beginning with Ace and ending with a king) , 13 hearts, 13 diamonds, and 13 clubs respectively.

This application is a form of the card game War or Battle. The application should load the deck. Make use of a loop to load the array. The application should allow the user or player to enter a value for their card. Be sure to validate their entry as a number between 0 and 51. Have the computer draw a random card from the deck. Compare the users card to the computers card and determine the winner. The winner has the card with the larger value. Aces are low. Remember card 0 is the ace of spades and has the same value as card 13 which is the ace of hearts. The winner of the round receives a point. Allow the user to continue playing until they are ready to stop. Make use of methods where appropriate. Display the winner of each round as well as the overall winner after the user quits the game.

This application should have a method that displays the suit and the rank of the card. Meaning if the user enters 14 the method will display 2 of Hearts. This method should be called to display the suit and rank of the user and computers card each round. You should make use of the following equations to determine the suit and rank of your card:

Suit: cardNum / 13

0 = Spades

1 = Hearts

2 = Diamonds

3 = Clubs

Rank: cardNum % 13

0 = Ace

1 = 2

2 = 3

3 = 4

4 = 5

5 = 6

6 = 7

7 = 8

8 = 9

9 = 10

10 = Jack

11 = Queen

12 = King

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!