Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. /*
  2. * Robert Thibodeau
  3. * 9/11/2019
  4. * CSC-111
  5. * Java Programming
  6. * Random Card
  7. * rthibodeau0001@student.stcc.edu
  8. * Picks a random card from one of the deck of 52
  9. */
  10. package randomcard;
  11.  
  12. public class RandomCard {
  13.  
  14. public static void main(String[] args) {
  15. String facecard;
  16. double num = (52 * Math.random());
  17. int card = (int) (num % 13);
  18. System.out.println("Your card is:");
  19. if (card == 1) {
  20. facecard = "Ace";
  21. System.out.println("The " + facecard + " of ");}
  22. else if (card == 11) {
  23. facecard = "Jack";
  24. System.out.println("The " + facecard + " of ");}
  25. else if (card == 12) {
  26. facecard = "Queen";
  27. System.out.println("The " + facecard + " of ");}
  28. else if (card == 0) {
  29. facecard = "King";
  30. System.out.println("The " + facecard + " of ");}
  31.  
  32. else
  33. System.out.println("The " + card + " of ");
  34.  
  35. int suit = ((int) (num / 13));
  36. if (suit == 0)
  37. System.out.println("Hearts. ");
  38. else if (suit == 1)
  39. System.out.println("Diamonds.");
  40. else if (suit == 2)
  41. System.out.println("Clubs.");
  42. else if (suit == 3)
  43. System.out.println("Spades. ");
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement