Wow!!!
Type: Posts; User: Norm
Wow!!!
Try writing a small testing program to work out the technique.
Define a testing class with a main() method.
Add these two lines to the main() method:
public class Testing {
public static void...
Here are the steps you need to do:
Define an int variable that will hold the index of the max value
In the loop where the search for the max value is done:
every time a value is assigned to the...
If candidate is an array then you can use it the same way you used the contents of the other arrays when printing.
This line seems to already use it:
System.out.println(candidate[i] + "\t" +...
You need to learn how to read the API doc for Java classes.
The API doc link: Java Platform SE 7
Find the link to the class in the lower left panel and click on it to get the API doc for the...
Look at the DecimalFormat class.
Yes that is correct.
AFTER computing the value of sum, then you can use sum to compute the percentage for each candidate in another loop.
percentage = candidates vote / the total votes * by 100
Did you understand my comment about computing the value of sum BEFORE using it to compute the percentage?
double percentage = (double) votes[i] / (double) sum * 100;
AFTER computing the value...
Can you use sum before you've added in all the values?
What variable contains: the candidates vote
and what variable has: the total votes
What is the formula for computing a percentage? What values should your program use?
Your code is not following the formula.
Define the variable outside of the brackets within the same pair of {}s where you want to print it.
Add values to the variable inside the loop.
What is the formula for computing a percentage? ...
The compiler can not find a definiton for the variable: i that is in scope(within the same pair of{}s) where it is being used. Check that i is defined for where you are trying to use it.
Please...