Sort an Array of Structs in c++ language. a. write a program that gets input fro
ID: 3806503 • Letter: S
Question
Sort an Array of Structs in c++ language. a. write a program that gets input from the user. b. write a program that read data from an external file. In this assignment, you are to create an array of structs and sort the array. 1. create a struct with (at least) 3 fields 2. create an array of structs 3. read data into the array of structs (9-11 records) 4. print all of the fields in the array (line up the columns) 5. sort the array (in ascending order) on 1 field of the struct 6. print all of the fields in the array 7. sort the array (in descending order) on another field of the struct 8. print all of the fields in the array Keep in mind that the fields of a struct all go together, and when you swap 1 field of a struct you need to swap ALL of the fields in the struct.
Explanation / Answer
struct Customers { string Name; string Id; float OrderAmount; float Tax; float AmountDue; }; const int MAX_CUSTOMERS = 1000; bool MoreCustomers(int); Customers GetCustomerData(); void OutputResults(Customers [], int); void SortData(const int, const int, Customers []); int main() { Customers c[MAX_CUSTOMERS]; int Count = 0; do { c[Count++] = GetCustomerData(); } while (MoreCustomers(Count)); for (int i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.