hehe, if you want the index you can't use the special for-each loop. You've got to do this:
for(int i = 0; i < votes.length; i++){
if(votes[i]>votes[highest]){
...
Type: Posts; User: helloworld922
hehe, if you want the index you can't use the special for-each loop. You've got to do this:
for(int i = 0; i < votes.length; i++){
if(votes[i]>votes[highest]){
...
I didn't want to just post the code cause then you wouldn't learn anything useful. Instead, I'll describe the thought process.
The winner in the election is the person that has the most votes*....
lol, oops. As you learn more about programming, you'll find that it's very rare there is only 1 right answer. However, there are a lot of wrong answers ;)
Create an initial array to hold the...
I'm effectively getting rid of the 2 helper methods you have. The reason is you can only return 1 value, but what you need is to get a candidate name and the number of votes. This is a possible...
oh, just print out only one string.
Scanner in = new Scanner(System.in);
for (int i = 0; i < enteredNames.length; i++)
{
System.out.println("Enter candidate's name and the votes received...
You're divinding int data types... Java is automatically truncating for you before casting it to float.
Cast the enteredVotes[i] to float so Java will auto-cast up to float at the beginning rather...