Thread: data arrangement and sorting.

  1. #1
    Registered User cdkiller's Avatar
    Join Date
    Feb 2006

    Question data arrangement and sorting.

    ok people the following is basically what i need assistance with. the problem assumes that all data from the input file is valid and should not contain validation checks. it also must not use vectors or similar storage entities. it also must not use goto statements. i must warn that the way the results are displayed below may be a bit retarded but basically it supposed to read numbers from a file, and for example is the number falls between 0 and 10 then that adds a unit to the "bin 0" as phrased. also since a half * cannot be displayed, appropriate approximations must occur when scaling the histogram.

    Design and implement a program to produce a histogram using numbers read from a file. The name of the data file is fixed and must be "data.txt", the number of bins is also fixed to 10. When run, your program will automatically read the numbers from the file and produce the histogram. The data in the file will only be valid numbers.

    The output looks like the following

    52 good data points
    0:0-10, 1:10-20, 2:20-30, 3:30-40, 4:40-50,
    5:50-60 6:60-70, 7:70-80, 8:80-90, 9:90-100

    0 0
    1 4 ****
    2 7 *******
    3 7 *******
    4 8 ********
    5 12 ************
    6 5 *****
    7 8 ********
    8 0
    9 1 *

    There are a maximum of 20 '*'s that can be placed on a line, therefore if the number of stars exceed the maximum, the numbers in the bins must be scaled appropriately. The ranges of each bin is determined after the all the data has been read.

    if you have read till this far then thank you. hope somebody out there is bored enough to do this code for me.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    I didn't read your whole post, but the histogram part reminded me of this.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Out of scope
    Quote Originally Posted by cdkiller
    hope somebody out there is bored enough to do this code for me.
    All aboard! Next stop, Closedville!
    Sent from my iPadŽ

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    I agree - closed.
    In the mean time, the original poster should read the homework policy and then start a new thread with some attempt at solving the problem.

Popular pages Recent additions subscribe to a feed