-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCC01S1.java
More file actions
97 lines (96 loc) · 2.66 KB
/
CCC01S1.java
File metadata and controls
97 lines (96 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.next();
char[] x = a.toCharArray();
int i = 1;
ArrayList<Character> c = new ArrayList<>();
ArrayList<Character> d = new ArrayList<>();
ArrayList<Character> h = new ArrayList<>();
ArrayList<Character> s = new ArrayList<>();
int cC = 0;
int dC = 0;
int hC = 0;
int sC = 0;
System.out.println("Cards Dealt Points");
System.out.print("Clubs ");
while(x[i] != 'D'){
c.add(x[i]);
switch(x[i]){
case 'A' ->{cC+=4;}
case 'K' -> {cC+=3;}
case 'Q' -> {cC+=2;}
case 'J' -> {cC+=1;}
}
System.out.print(x[i]+" ");
i++;
}
switch(c.size()){
case 0 -> {cC+=3;}
case 1 -> {cC+=2;}
case 2 -> {cC+=1;}
}
System.out.println(cC);
i++;
System.out.print("Diamonds ");
while(x[i] != 'H'){
d.add(x[i]);
switch(x[i]){
case 'A' -> {dC+=4;}
case 'K' -> {dC+=3;}
case 'Q' -> {dC+=2;}
case 'J' -> {dC+=1;}
}
System.out.print(x[i]+" ");
i++;
}
switch(d.size()){
case 0 -> {dC+=3;}
case 1 -> {dC+=2;}
case 2 -> {dC+=1;}
}
System.out.println(dC);
i++;
System.out.print("Hearts ");
while(x[i] != 'S'){
h.add(x[i]);
switch(x[i]){
case 'A' -> {hC+=4;}
case 'K' -> {hC+=3;}
case 'Q' -> {hC+=2;}
case 'J' -> {hC+=1;}
}
System.out.print(x[i]+" ");
i++;
}
switch(h.size()){
case 0 -> {hC+=3;}
case 1 -> {hC+=2;}
case 2 -> {hC+=1;}
}
System.out.println(hC);
i++;
System.out.print("Spades ");
while(i < x.length){
s.add(x[i]);
switch(x[i]){
case 'A' -> {sC+=4;}
case 'K' -> {sC+=3;}
case 'Q' -> {sC+=2;}
case 'J' -> {sC+=1;}
}
System.out.print(x[i]+" ");
i++;
}
switch(s.size()){
case 0 -> {sC+=3;}
case 1 -> {sC+=2;}
case 2 -> {sC+=1;}
}
System.out.println(sC);
System.out.print("Total ");
System.out.print(cC+dC+hC+sC);
}
}