### Structs

This program is supposed to read from the input file into an array of structs, compute one additional value per record, sorts the array based on this calculated field, print portions of the sorted record to both the screen and an output file. This is the code so far...I need help defining the struct and writing the function to compute all the totals...

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657`` ``````// use proper includes using namespace std; struct record { // define fields of struct }; void swap(record A[], int i, int j); void sort_based_on_total(record A[], int size); int main() { record data[3000]; // array of records (structs) ifstream indata; indata.open("sales.txt"); ofstream outdata; outdata.open("ordered_by_total.txt"); int i=0; indata >> data[i].name >> data[i].item >> data[i].style >> data[i].price >> data[i].quantity; while(!indata.eof()) { i++; indata >> data[i].name >> data[i].item >> data[i].style >> data[i].price >> data[i].quantity; } for(int j=0; j < _____; j++) // determine condition { // compute all totals } // call sort_based_on_total for(int j=0; j < _____; j++) // determine condition { cout << data[j].name << "\t" << data[j].total << endl; // print to screen outdata << data[j].name << "\t" << data[j].total << endl; // print to file } indata.close(); outdata.close(); return 0; } void swap(record A[], int i, int j){ // write code to define swap } void sort_based_on_total(record A[], int size){ // write code to define sort_based_on_total } ``````

use this data to test code

Dwight Note Imagine 62.50 1
Jim Note Imagine 62.50 1
Karen Note Imagine 62.50 1
Michael Note Impression 88.50 1
Phyllis Note Inspire 74.90 1
Phyllis Note Inspire 74.90 1
Ryan Note Imagine 62.50 1
Ryan Note Imagine 62.50 2
Stanley Note Impression 88.50 1