Search:

Type: Posts; User: helloworld922

Search: Search took 0.09 seconds.

  1. [SOLVED] Re: My Voting Program

    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]){
    ...
  2. [SOLVED] Re: My Voting Program

    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*....
  3. [SOLVED] Re: My Voting Program

    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...
  4. [SOLVED] Re: My Voting Program

    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...
  5. [SOLVED] Re: My Voting Program

    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...
  6. [SOLVED] Re: My Voting Program

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