Question: votes - 1 . txt votes - 2 . txt votes - 3 . txt votes - 4 . txt votes - 5 . txt

votes-1.txt
votes-2.txt
votes-3.txt
votes-4.txt
votes-5.txt
In JAVA using Array/Scanner/beginner java code. Write a program that reads voting data from a file and then shows the result.
Display the total number of votes received for Mahatma Gandhi, Mother Teresa, and Nelson Mandela. Ignore any other candidate.
Test Case 1
Enter the name of the file with votes: votes-1.txt [enter]
Voting Results:
Mahatma Gandhi: 6 votes
Mother Teresa: 2 votes
Nelson Mandela: 2 votes
Test Case 2
Enter the name of the file with votes: votes-2.txt [enter]
Voting Results:
Mahatma Gandhi: 15 votes
Mother Teresa: 14 votes
Nelson Mandela: 21 votes
Test Case 3
Enter the name of the file with votes: votes-3.txt [enter]
Voting Results:
Mahatma Gandhi: 55 votes
Mother Teresa: 64 votes
Nelson Mandela: 81 votes
Test Case 4
Enter the name of the file with votes: votes-4.txt [enter]
Leonardo da Vinci is not a valid candidate.
Rosa Parks is not a valid candidate.
Rosa Parks is not a valid candidate.
Rosa Parks is not a valid candidate.
Rosa Parks is not a valid candidate.
Voting Results:
Mahatma Gandhi: 5 votes
Mother Teresa: 4 votes
Nelson Mandela: 6 votes
votes - 1 . txt votes - 2 . txt votes - 3 . txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!