-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvestingGameRank.java
80 lines (53 loc) · 2.4 KB
/
InvestingGameRank.java
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
import java.util.*;
import java.util.stream.Collectors;
/**
* A class that demonstrates the basic usage of {@link Map}s.
*
* @version 1.0
*/
public class InvestingGameRank {
/**
* The main entry point to the program.
*
* @param args Command line arguments
*/
public static void main(String[] args) {
/**
* How do I do this?
*
* Store the names and their corresponding scores
*/
String[] names = {"Cmorreale", "Emre S.", "Artem F", "Mehul C.", "Anand P." , "Aravind S.", "Harsh", "John Ireland", "Soosup", "Walter t", "Helena young", "Brkeene", "Maysa F", "lily sigman", "wbfinv", "dsafdfa", "John K.", "Ronit K", "Gabe A.", "Daksh G", "Pdhakad", "Jpthesmar", "Sofiaxie", "Azizah", "Zach Newburg", "Talha Q", "Musalan", "Ryhannigan", "jetcloudz", "Syed S", "Luhai tang", "Amir J", "Abroche", "Ali R", "a12w", "Drago21", "Ethan F"};
int[] wealth = {114570, 105978, 100666, 154351, 100452,100000, 100000,100000,100000,100000,100000,100000, 100000, 100000, 100000,101287,100000,100000, 100000,100000,100000,100249,100133, 100232,99216,99490,108812,97939,99884,99343, 99537, 99215, 98188, 98665,76507, 41312, 1000};
int[] attendanceCount = {};
Map<String, Integer> attendance = new HashMap<>();
Map<String, Integer> nameValue = new HashMap<>();
for(int i = 0; i< names.length; i++)
{
nameValue.put(names[i],wealth[i]);
Scanner scan = new Scanner(System.in);
System.out.println("How many meetings did " + names[i] + " attend?");
int attendanceNum = scan.nextInt();
System.out.println("attendance number is "+attendanceNum);
nameValue.put(names[i],wealth[i]+ (5000) * attendanceNum );
}
// TODO: Add words and frequency
Map<String, Integer> sortedMap = nameValue.entrySet().stream()
.sorted(Comparator.comparingInt(e -> -e.getValue()))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(a, b) -> { throw new AssertionError(); },
LinkedHashMap::new
));
sortedMap.entrySet().forEach(System.out::println);
}//end main
}
/**
* Winners
* Mehul C.=154351
* Cmorreale=129570
* Emre S.=115978
* Musalan=113812
* Zach Newburg=109216
*/