Ok here is my assignment, i know its alot to read, but i would really appreciate the help:

Write a program that asks the user for a file name. The file contains the part number, cost and quantity for up to 50 parts in the current inventory at a store.

Your program should:
• Read the data into parallel arrays. Use integer arrays for the part number and quantity and a float or double array for the cost.
• Calculate the value of each item. Use another float or double array to store the value. This array will be in parallel with the other 3.
• Display the following information for the value array:
o The lowest number in the array
o The highest number in the array
o The total of the numbers in the array
o The average of the numbers in the array
o The array’s contents sorted in ascending order (use the bubble sort)
o The median value of the array. The median is the middle value, when the data is sorted, or the average of the 2 middle values when there are an even number of values.

• For extra credit, you may dual sort the part number and value arrays (modify the dual sort function in the book to use the bubble sort algorithm and work in ascending order) and display both the part number and value for the items shown above.

You should have separate functions to read the data, perform each calculation shown above, and print the results. In your read function, be sure to count how many numbers are actually read into the array. The rest of your functions should use this count to process the array’s contents.

Write your results to the file results.txt. Your output should be nicely formatted and easy to read.

And here is what my coding looks like so far:

#include <iostream>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

void sortArray( int[], int);

int main()
    const int ARRAY_SIZE = 10;
    int numbers[ARRAY_SIZE];
    int count, total, median, max, min, sum, size;
    ifstream inputFile;
    ofstream outputFile;

    // opens the file containing inventory data

    for (count = 0; count < ARRAY_SIZE; count++)
        inputFile >> numbers[count];
    // closes the file
    sortArray( numbers, 10);

void sortArray(int array[], int size)
     bool swap;
     int temp;
         swap = false;
         for (int count = 0; count < (size-1); count++)
             if( array[count] > array[count+1])
                 temp = array[count];
                 array[count] = array[count+1];
                 array[count+1] = temp;
                 swap = true;
                 } while (swap);

// Sorts the array and determines the median value.
double median( int x[], int size )
	// If the size is odd the median is x [size / 2 ]
	// If the size is even the median is the average
	// of the two middle elements x[(size - 1)/2] and x[size/2]
	if (size % 2 != 0) // odd size
		return x [ size / 2];
	else if
		return ( x [ (size – 1) / 2] + x [ size / 2] ) / 2.0 ;    
    // min and max
    for ( int i = 1; i < arraySize; i++ )
          if ( a[ i ] > max )
			max = a [ i ];
		else if ( a [ i ] < min )
			min = a [ i ];        

   // total           
   for ( int i = 0; i < arraySize; i++ )
          total += a[ i ];    

// compute the mean              
double mean( const int x[], int arraySize )
       int sum = 0;
       // sum the array values
       for ( int i = 0; i < arraySize; i++ )
          sum += x[ i ];
	 return  static_cast< double >( sum ) / arraySize;

  // Open the file that the array will be written to.

  // Writes the array into the output file.
  for (count = 0; count < ARRAY_SIZE; count++)
           outputFile  <<  numbers[count] << endl;

           // Closes the output file.

Any corrections or help would be great!! Thanks!!

Please use code tags, [code=cplusplus] [/code] also please try to post a specific question. We will not just do the rest of your project for you. You need to actually hve a problem before we can answer it.


again, i'm new to programming so what do you mean by code tags?
And really what i am asking is why won't this compile? Am I attempting find put the information into arrays the right way and am I trying to find the high, low and average correctly?

>And really what i am asking is why won't this compile?
Probably because you haven't yet learned to program incrementally. Scrap your code and start over, this time write just a little bit before making sure it'll compile and works as expected. Write a little more, then compile again and make sure it works as expected. Do this and you won't find yourself constantly overwhelmed with pages of legitimate errors.

Unfortunately, I am short on time. This program is due at midnight and i work 5-10 tonight. If you can't help me, its understandable but anything at all would be appreciated. Thanks again.