Complete the program that processes an array of structured data. Use the given template and complete those portions indi

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Complete the program that processes an array of structured data. Use the given template and complete those portions indi

Post by answerhappygod »

Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 1
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 1 (41.06 KiB) Viewed 28 times
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 2
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 2 (20.17 KiB) Viewed 28 times
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 3
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 3 (44.19 KiB) Viewed 28 times
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 4
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 4 (31.34 KiB) Viewed 28 times
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 5
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 5 (31.9 KiB) Viewed 28 times
my output
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 6
Complete The Program That Processes An Array Of Structured Data Use The Given Template And Complete Those Portions Indi 6 (17.63 KiB) Viewed 28 times
Complete the program that processes an array of structured data. Use the given template and complete those portions indicated in the template. The program has defined a structure named Sale. The structure has the following fields: string itemName int quantity double unitPrice The main function calls loadUserInput which returns a pointer to the first Sale element in the dynamically allocated array of Sale elemer and an integer for the number of Sale elements in the array. The main function then calls printData to show the sale items including the total of each sale item and the total of the entire list. Function printData This is the function you need to complete as well as two other helper functions. In the function body, print the report heading. Then iterate through the array received through the parameters and print the data according to the required format. For the total of eac item, call getItem Total. At the end of the report, print the total of the entire sale items by calling getTotal. Test The Program Use the following input data: 5 Milk 1 5.85 Whole Wheat Bread. 2 3.75 Napkin 3 2.35 Paper Towel 3 2.95 Soap 1
2 3.75 Napkin 3 2.35 Paper Towel 3 2.95 Soap 1 1.95 The output should look exactly as follows: Sales Item Bread Milk Whole Wheat Bread. Napkin Paper Towel Soap Total Qty 1 2 3 3 1 Unit 5.85 3.75 2.35 2.95 1.95 Amt 5.85 7.50 7.05 8.85 1.95 31.20
main.cpp Download 4 5 #include <iostream> 6 #include <iomanip> 7 24 25 26 8 using namespace std; 9 10 struct Sale { 11 12 13 14 }; 15 16 Sale getUserInput(int items); 17 double getItemTotal (const Sale *sale); 18 double getTotal (const Sale salePtr, int items); 19 void printData(const Sale salePtr, int items); 20 27 28 string itemName; int quantity; // name of sale item // quantity of item double unitPrice; // unit price of item .. 21 int main(int argc, const char * argv[]) { 22 int items [0]; 23 Sale users printData(users, items); getUserInput(&items); main.cpp delete users; return 0; 29 30 //**** **** 31 // getUserInput This function gets a list of Sale item from the user. 32 // This functions dynamically allocates an array and returns a pointer to the allocated array. The caller is responsible for deleting the allocated array. 33 // 34 //* 35 //* 36 // Parameters: 37 //* items pointer to the callers variable for item counts. 38 // 39 // Return: 40 //* The pointer to the first Sale item in the allocated array of Sale 41 // items. 42 //* Load default template.
67 // 68 // 69 // Parameters: 70 //* salePtr pointer to one sale item 71 //* 72 // Return: 73 // 74 // 79 80 sale item. 75 //*****...... 76 double getItemTotal (const Sale sale) { 77 // Write your code here... 78 The total price of the item. 101 102 81) 82 83 84 // getTotal This function returns the total price of the sale items. 85 // 86 // Parameters: 87 //* solePtr pointer to the first sale item 88 // items number of sale items 89 // 103) 104 return sale quantity sale-> unitPrice; 90// 91 //* 92 // 93 //*****......... 94 double getTotal (const Sale salePtr, int items) { 95 // Write your code here.... 96 97 98 99 100 Return: The total price of the items. ******* double total 0: for(int i=0; i < items; i++) total getItemTotal (salePtr+i); D return total; 105 106 // printData- This function prints a report of the sale items. I
96 double total -0, 97 for(int i=0; i< items; i++) 98 99 total getItemTotal (salePtr+i); 100 101 eturn total; 102 103 104 105 106 printData- This function prints a report of the sale items. 107 108 Parameters: 109 salePtr 110 items number of sale items 111 112 Return: 113 void 114 115 116 printData(const Sale salePtr, int items) { pointer to the first sale item 117/ Write your code here... 118 ut << "Sales" << endl; ***** 119 cout <<setw(20) << left << "Item" << right <<setw(4) <<"Qty" <<setw(8) << "Unit"<<setw(9) <<"Amt"<<< enc 120 cout << setfill('') <<setw(40) << "" << endl; 121 cout << setfill(' '); 122 cout<<setprecision (2) << fixed; 123 for(int i = 0; i < items; i++) 124 125 126 cout<<setw(20) << left << salePtr.itemName << right <<setw(4) << salePtr.quantity <<setw(8) < cout<<endl<<setw(32)<<left<<"Total" <<setw(8) << right << getTotal (salePtr, items) << endl; 127 128
Sales Item Milk Whole Wheat Bread Napkin Paper Towel Soap Total Qty Unit 1 2 3 3 1 5.85 3.75 2.35 2.95 1.95 Amt 5.85 7.50 7.05 8.85 1.95 31.20
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply