-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElectionDriver.java
More file actions
205 lines (129 loc) · 7.08 KB
/
Copy pathElectionDriver.java
File metadata and controls
205 lines (129 loc) · 7.08 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//Camryn Bickerstaff
//
//
import java.io.*;
import java.util.*;
public class ElectionDriver
{
public static void main(String[] args) throws Exception
{
File file = new File("Election.txt");
Scanner input = new Scanner(file);
State[] states = new State[51];
Candidate[] candidate = new Candidate[2];
candidate[0] = new Candidate("Phillip J. Fry", "New York", "R");
candidate[1] = new Candidate("John A. Zoidberg", "California", "D");
for(int i = 0; i <= 50; i++)
{
states[i] = new State(input.next(), input.nextInt(), input.nextInt(), input.next());
input.nextLine();
}
System.out.println("At this election in year 3000, " + candidate[0].getName() + " a " + candidate[0].getParty() + " from " + candidate[0].getState() + " is \nrunning against " + candidate[1].getName() + " a " + candidate[1].getParty() + ", who is originally from \nDecapod 10, but claims his home state is " + candidate[1].getState() + ".\n");
Thread.sleep(1000);
//popular votes for each state
for(int i = 0; i <= 50; i++)
{
states[i].populationVotes();
states[i].getVotes();
//Thread.sleep(700);
System.out.println("");
System.out.println("At " + states[i].getName() + ", a " + states[i].getParty() + " state, ");
if(states[i].getDemVotes() > states[i].getRepVotes())
{
System.out.println(" " + candidate[1].getName() + " beat " + candidate[0].getName() + " with a " + states[i].getDemVotes() + " to " + states[i].getRepVotes() + " win!\n");
}
else if(states[i].getRepVotes() > states[i].getDemVotes())
{
System.out.println(" " + candidate[0].getName() + " beat " + candidate[1].getName() + " with a " + states[i].getRepVotes() + " to " + states[i].getDemVotes() + " win!\n");
}
}
System.out.println("\n\n\n\n\n\n\n\n");
System.out.println(" Results:\n");
//total popular votes for candidates
int totalDemVotes = 0;
int totalRepVotes = 0;
for(int i = 0; i <= 50; i++)
{
totalDemVotes = totalDemVotes + states[i].getDemVotes();
totalRepVotes = totalRepVotes + states[i].getRepVotes();
}
if(totalDemVotes > totalRepVotes)
{
System.out.println(candidate[1].getName() + " won the popular vote over " + candidate[0].getName() + " with a " + totalDemVotes + " to \n " + totalRepVotes + " win!\n\n\n\n" );
}
else if(totalRepVotes > totalDemVotes)
{
System.out.println(candidate[0].getName() + " won the popular vote over " + candidate[1].getName() + " with a " + totalRepVotes + " to \n " + totalDemVotes + " win!\n\n\n\n" );
}
//total electoral votes for candidates
int totalEleDem = 0;
int totalEleRep = 0;
for(int i = 0; i<= 50; i++)
{
states[i].getElectoralVote();
if(states[i].getDemVotes() > states[i].getRepVotes())
{
totalEleDem = totalEleDem + states[i].getElectoralVote();
}
else if(states[i].getRepVotes() > states[i].getDemVotes())
{
totalEleRep = totalEleRep + states[i].getElectoralVote();
}
}
//Final Results (Electoral Vote Winner)
if(totalEleDem > totalEleRep)
{
System.out.println(" " + candidate[1].getName() + " beat " + candidate[0].getName() + " with a " + totalEleDem + " to " + totalEleRep + " win!\n");
}
else if(totalEleRep > totalEleDem)
{
System.out.println(" " + candidate[0].getName() + " beat " + candidate[1].getName() + " with a " + totalEleRep + " to " + totalEleDem + " win!\n");
}
System.out.println(" Presenting your new President! Zoidberg!");
System.out.println(" __....-------....__");
System.out.println(" ..--\'\" \"`-..");
System.out.println(" .\'\" `.");
System.out.println(" :\' `,");
System.out.println(" .\' \".");
System.out.println(" : :");
System.out.println(" : b");
System.out.println(" d `b");
System.out.println(" : :");
System.out.println(" : b");
System.out.println(" : q");
System.out.println(" : `:");
System.out.println(": :");
System.out.println(",' :");
System.out.println(": _____ _____ p'");
System.out.println(" \\,.-\' `-. .-\' `-. :");
System.out.println(".\' `. .' `. :");
System.out.println("/ \\ / \\ p'");
System.out.println(": @ ; : @ ; :");
System.out.println("| | | | :");
System.out.println(": ; : ; ,:");
System.out.println(" \\ / \\ / p");
System.out.println(" /`. .' `. .' :");
System.out.println("q_ `-._____.-. `-._____.-' :");
System.out.println(" /-__ .\"\" \"-.__ :'");
System.out.println("(_ \"\"-.\' \"\"\"---bmw :");
System.out.println(" \"._.-\"\" ,:");
System.out.println(" ,\"\" P");
System.out.println("\".\" :");
System.out.println("\" _.\" .\" .\" _... :");
System.out.println("P .\" \" .\' ,\"####) :");
System.out.println(": .\" .\" / ,'######' :");
System.out.println(": : ( ,\" ,########: ,:");
System.out.println(" q `. '. , :######,-' :");
System.out.println(" `: b q : '--''\"\" :");
System.out.println(" : : : : : :");
System.out.println(" : : `: `. \". :'");
System.out.println(" q_ : : : ) :");
System.out.println(" \"\"\'b`._ ,.`.____,\' `._ _.\' ,");
System.out.println(" |.__\"\"\" \"\"\" _______.......\',");
System.out.println(" ,\' \"\"\"\"\"\"\"-----.------\"\"\"\"\"\"\" :");
System.out.println(" : : :");
System.out.println(" : : :");
System.out.println(" :.__ : ________.......,\'");
System.out.println(" \"\"\"\"\"\"\"\"------\'------\"\"\"\"\"\"");
}
}