Access over 20 million homework & study documents
search

Programming Questions 1

Content type

User Generated

Subject

Computer Science

Type

Homework

Rating

Showing Page:
1/6

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/6

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/6

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 6 pages?
Access Now

Unformatted Attachment Preview

Programming Questions Question 1: Problem: Write a program that simulates picking a card from a deck of 52 cards. Your program should display the rank (Ace, 2,3,4,5,6,7,8,9,10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card. Out the program works: The java program on a card pick uses random number to randomly select rank and a suit. ON each run the user can get the rank and the suit which is selected. Source code and pseudocode: /** * *Program Name : Game: pick a card * *Program desc:a Java program that simulates picking a card from a deck of 52 cards. * The program display the rank (Ace, 2,3,4,5,6,7,8,9,10, Jack, Queen, King) and * suit (Clubs, Diamonds, Hearts, Spades) of the card. * * Algorithm in pseudocode: * Start the class * Implement the main method * generate random numbet between 1 and 13 for rank * generate random number for suit 1 to 4 * use switch to output a rank * use switch to output suit * end the program * * * @author * @version 1.0 * @since 2018-12-04 */ public class Pick_a_Card { public static void main(String[] args) { /** * This is the main method * @param args Unused. * @return Nothing. * @exception IOException On input error. * @see IOException */ //random number between 1 and 13 int rank = (int)((Math.random() * (14 - 1)) + 1); //random number between 1 and 4 int suit = (int)(Math.random() * 4); //show the card System.out.print("The card you picked is "); switch(rank) // Get rank { case case case case case case case case ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Super useful! Studypool never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4