-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHayPoints.java
More file actions
38 lines (36 loc) · 1.23 KB
/
Copy pathHayPoints.java
File metadata and controls
38 lines (36 loc) · 1.23 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
import java.util.HashMap;
import java.util.Scanner;
public class HayPoints {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int words = sc.nextInt(), descriptions = sc.nextInt();
int score = 0;
HashMap<String, Integer> map = new HashMap<>();
String job; int value;
String line;
String[] lineArr;
// add to map
for (int i = 0; i < words; i++) {
job = sc.next(); value = sc.nextInt();
map.put(job, value);
}
// get rid of blank
sc.nextLine();
// check the job descriptions
for (int j = 0; j < descriptions; j++) {
line = sc.nextLine();
while(!line.equals(".")){
// iterate through the line to see if any keywords
lineArr = line.split(" ");
for (int k = 0; k < lineArr.length; k++) {
if(map.get(lineArr[k]) != null){
score += map.get(lineArr[k]);
}
}
line = sc.nextLine();
}
System.out.println(score);
score = 0;
}
}
}