Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    Wow!!!
  2. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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...
  3. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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...
  4. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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" +...
  5. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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...
  6. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    Look at the DecimalFormat class.
  7. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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
  8. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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...
  9. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    Can you use sum before you've added in all the values?
  10. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    What variable contains: the candidates vote
    and what variable has: the total votes
  11. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    What is the formula for computing a percentage? What values should your program use?

    Your code is not following the formula.
  12. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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? ...
  13. Replies
    25
    Views
    4,587

    Re: Percentage Array Help

    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...
Results 1 to 13 of 13