Hello, I recently recieved this lab for my computer science class, but I was absent the day we learned how arrays work, so I am having a tought time with this one. I have searched the bowels of the internet as well as my textbook and it all is mandarin too me as I am still lost. The project entails I-
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.
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:"
Any help is much appreciated as I am currently working on it because it is do soon. Thank You for your time.
I'm sorry I was under the impression the numbers had copied into my question.
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
According to the instructions they are just one line
@OvO: std::exit is perfectly cross-platform. The value 1 as its argument is not. If you are going to point out that it's wrong, at least say why: the constant EXIT_FAILURE should be used instead.
@LB Never mind, I took no offense, just justifying my motives! I suggest first reading the file into a string and then converting it to a char, then using a for loop, go through the char and extract numbers from it, convert char to integer ( int ) and insert them into an array, then compare them. I have not had the liberty of time to give complete code, but I will give you reading the whole file into a std::string and a link to how to convert a std::string to a char * and converting char to int.
Reading to std::string: