-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrToNum.java
More file actions
99 lines (40 loc) · 1.14 KB
/
Copy pathStrToNum.java
File metadata and controls
99 lines (40 loc) · 1.14 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
import java.util.Scanner;
public class StrToNum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int sum = 0;
if(s.length() < 0) {
System.out.println(sum);
}
for(int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
case 'A':
sum += 1;
break;
case 'B':
sum += 10;
break;
case 'C':
sum += 100;
break;
case 'D':
sum += 1000;
break;
case 'E':
sum += 10000;
break;
case 'F':
sum += 100000;
break;
case 'G':
sum += 100000;
break;
default:
sum += 0;
}
}
System.out.println(sum);
}
}