TXT File Array C++

Need Help With This Project I recieved in school. I am having a tough time understanding how to complete this project Any help is appreciated. Thank You for your time.
Create a new project in Code Blocks for a program that will:
Read in a file of sales dollar amounts (doubles) and store them in an array.
The maximum number of amounts that the file could
contain is 20, but it could have less, and
zero (0.00) marks the end of the valid data.

Your program should read in the data and :
Determine the smallest amount in the file.
Determine the largest amount in the file
Sort the amounts from lowest to highest.

2. The program will output to a file the following items:
"The number of sales amounts in the file is "
"The lowest sales amount is "
"The highest sales amount is "
"Here is the list of amounts sorted from lowest to highest:"

3. Create and use a test file with the following values in the order that they appear below:
29.95, 3.55, 34.70, 12.34, 2.67, 33.89, 24.99, 18.45, 4.99, 9.95, 0.00




#include <fstream>
#include <iostream>
#include <cstdlib>

void FillArray(int a[], int size, int number_used);
void Sort(int a[], int number_used);
void Smallest(const int a[], int start_index, int number_used);
void Largest(const int a[], int end_index, int number_used);
void Output();

double Arrow, Sorted, Small, Large;

int main()
{
using namespace std;

ifstream InStream;
ofstream OutStream;




InStream.open("file.txt");
if (InStream.fail())
{
cout << "Input file opening failed.\n";
exit(1);;
}
OutStream.open("file.txt");
if (OutStream.fail())
{
cout << "Input file opening failed.\n";
exit(1);;

int Array[20], number_used;

Arrow = void FillArray()
Sorted = void Sort(Array, number_used);
double Small = void Smallest(const int a[], int start_index, int number_used);
double Large = void Largest ());

InStream.close( ); // Close Files Outta Loop
OutStream.close( );
cout << "The program has completed successfully.\n";
return 0;

} // End Main

//Functions

FillArray(int a[], int size int number_used);
{using namespace std;
int Next, index = 0;
InStream >> Next;
while ((Next >= 0) && (index < size))
{a[index] = Next;
index++;
InStream >> Next;
}
number_used = index;
}

void Sort(int a[], int number_used);
{
int IndexNextSmallest;
for (int index = 0; index < number_used -1; index++)
IndexNextSmallest =
IndexOfSmallest(a, index, number_used)
}






void Smallest (const int a[], int start_index, int number_used);








void Largest (const int a[], int end_index, int number_used);





void Output() // Output Section
{
out_stream.setf(ios::fixed);
out_stream.setf(ios::showpoint);
out_stream.precision(2);


out_stream << "The Number Of Sales Amounts In The File Is " << Arrow << endl;
out_stream << "The Lowest Sales Amount Is $ " << Small << endl;
out_stream << "The Highest Sales Amount Is $" << Large << endl;
out_stream << "List Of Sorted Numbers " << Sorted << endl << endl;
}
Last edited on
Topic archived. No new replies allowed.