program reads from a file (sales.txt) containing records in the format string int double. the string is a productID, the int is a quantity, and the double is a price. It stores this data in three parallel arrays. program then uses function, computeTotal, to compute
the total sales for each record. it uses a second function, maxSales, to find the largest total and
the corresponding index. I have most of the code done, I just need to write the functions and make the program output in to a file report.txt ( "The biggest sale occurs for product ID **** in the amount of $****" )
I completely went blank when I started to write the functions...I know its simple I feel like I am making it more complex than it is.
#include <iostream>
#include <string>
#include <fstream>
usingnamespace std;
void computeTotal(int quantity[], double price[], double total[], int size)
{
// write code to populate the total array here
return; // no value is returned
}
double maxSales(double total[],int& maxValIndex, int size)
{
// write code here to determine the max total value and the index where it occurs
return maxVal;
}int main()
{
string productID[25];
int quantity[25], index;
double price[25],total[25];
ifstream indata;
indata.open("sales.txt");
ofstream outdata;
outdata.open("report.txt");
int i=0;
indata >> productID[i] >> quantity[i] >> price[i];
while(!indata.eof())
{
i++;
indata >> productID[i] >> quantity[i] >> price[i];
}
computeTotal(quantity, price, total, i); // function call
double biggestSale = maxSales(total,index,i); // function call
// output code goes here
indata.close();
outdata.close();
return 0;
}