NEED HELP WITH AN ARRAY PROGRAM (LIST OF NUMBERS)

Hello to all who are reading this. I need to write a program that will get the length of a 64 number list from input, and then have the computer figure out the average, and the median. The numbers need to be aranged in order from least to greatest, and the frequency of the numbers also has to be printed out. The numbers to be used in this list are greater than or equal to 7 and less than or equal to 21. If anyone can help me write this program, I would appreciate it GREATLY!!!!:) Thanks!


-Jack


Comments

  • : Hello to all who are reading this. I need to write a program that will get the length of a 64 number list from input, and then have the computer figure out the average, and the median. The numbers need to be aranged in order from least to greatest, and the frequency of the numbers also has to be printed out. The numbers to be used in this list are greater than or equal to 7 and less than or equal to 21. If anyone can help me write this program, I would appreciate it GREATLY!!!!:) Thanks!
    :
    :
    : -Jack

    Hmmm. Sounds like a school assignment, but I'm feeling generous today so I'll help you out. You get the numbers in the array, and then use this code to do the rest:

    DIM number(1 to 64) AS INTEGER

    'Put the numbers in the array

    'Find out how many numbers:

    for a = 1 to 64
    if number(a) = 0 then exit for 'If it has not been entered
    next a
    NumOfNums = a

    'Sort the array:

    For a = 1 to NumOfNums
    For b = 1 to NumOfNums-1
    if number(b) > number(b+1) then
    temp = number(b+1)
    number(b+1) = number(b)
    number(b) = temp
    END IF
    NEXT
    NEXT

    'Mean (average):

    For a = 1 to NumOfNums
    sum = sum + number(a)
    next a
    mean = sum/NumOfNums
    Print "Mean:"; mean

    'Median

    if NumOfNums MOD 2 = 0 then 'If it is even
    median = (number(NumOfNums/2)+number(NumOfNums/2+1))/2
    else
    median = number(NumOfNums/2+.5)
    end if
    Print "Median:"; median

    'Frequency:

    Print "Frequency:"
    For a = 7 to 21
    count = 0
    for b = 1 to NumOfNums
    if number(b) = a then count = count + 1
    next b
    print a, count
    next a

    'If you need to print out the sort numbers, it would look like:

    for a = 1 to NumOfNums
    print number(a),
    next a

    There may be a few typos (i haven't tested this).
    Good Luck.


    URL:http://www.geocities.com/dfriend101

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories