Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- //Scanner card sign
- Scanner s = new Scanner(System.in);
- String input = s.nextLine();
- //create string of all card signs
- String strCards = "2 3 4 5 6 7 8 9 10 J D K A";
- //create array of strings with card signs
- String [] cardSigns = strCards.split(" ");
- //create array of all card suits
- String [] suits = {"spades","clubs","hearts","diamonds"};
- //iterate through array of suits up to scanned sign included
- for(String card:cardSigns){
- //nest iteration with suits for every sign
- for(String suit: suits){
- //no coma after last suit
- if (suit.equals( "diamonds")){
- System.out.print(card + " of "+ suit);}
- else {
- System.out.print(card + " of "+ suit+", ");
- }
- }
- //when reach card sign equal to input sign we stop iterating
- if (card.equals(input) ){
- break;
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement