Hello, I'm creating a simple voting program. Everything works apart from that the program wont calculate the % total of votes for each candidate. It displays each candidates percentage as 0.00%. I've tried everything to see why it does this but I'm fooled :(
import uulib.*;
public class Candidates
{
public static void main(String[] args)
{
final int CandidateNo = 5;
String[] Names = new String[CandidateNo];
int[] Votes = new int[CandidateNo];
double PercentTotal = 0;
int Totalv = 0;
for(int i = 0; i < Names.length; i=i+1)
{
Names[i] = Console.getString("Enter Candidate Last Name");
Votes[i] = Console.getInt("Enter Votes for " + Names[i]);
Totalv = Totalv + Votes[i];
}
System.out.println("\nCandidate\t Votes Received\t\t % of Total Votes\n");
for(int i = 0; i < Names.length; i=i+1)
{
PercentTotal = Votes[i] / Totalv * 100;
System.out.println(Names[i] + "\t\t" + Votes[i] + "\t\t\t" + PercentTotal);
}
System.out.println("\nTotal\t\t" + Totalv);
}
}
Any help will be greatly appreciated!
Cheers,
Stu.