Results 1 to 3 of 3
  1. #1
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Posts
    111
    Rep Power
    0

    Default get the average and maximum score

    Hello, I can get the average and maximum score on this example:

    Java Code:
    import java.util.Arrays;
    
    public class ArrayDemo1 {
    public static void main(String args[]) {
    double scores[] = {84.2,76.4,92.0,98.9,81.3};
    
    System.out.println("The scores are:");
    for (int i = 0; i < scores.length; i++) {
    System.out.println(scores[i]);
    }
    }
    }
    Thanks.

    Eric
    Last edited by Eric; 07-01-2007 at 04:16 AM.

  2. #2
    Marcus is offline Member
    Join Date
    Jun 2007
    Posts
    92
    Rep Power
    0

    Default

    Well, how would you find the average of several numbers if you weren't programming?

    I find that it is useful to write out what you'd want to do in words rather than code and then turn that into code.

    Marcus:cool:

  3. #3
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Posts
    111
    Rep Power
    0

    Default

    Hi, thanks a lot your comments , i know i can get the average by adding all these numbers and divide them by 5:

    average=(84.2+76.4+92.0+98.9+81.3)/5

    and the maximum number is 96.8 but i want to know how can i code them
    as an arrays and ask java to calculate them and print the result.


    Thanks.

    Eric

Similar Threads

  1. Calculate Average
    By sthack99 in forum New To Java
    Replies: 4
    Last Post: 06-13-2008, 11:09 AM
  2. show a high score from tetris
    By stessie in forum Java Applets
    Replies: 0
    Last Post: 03-19-2008, 03:00 AM
  3. Replies: 2
    Last Post: 07-03-2007, 04:09 PM
  4. Klaverjas Score 0.2
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-23-2007, 07:40 AM
  5. Maximum size of an array
    By Hasan in forum New To Java
    Replies: 1
    Last Post: 05-20-2007, 11:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •