Question: need help with this c++ program #include #include using namespace std; //TODO: Create your struct int main() { const int SIZE = 3; Item inventory[SIZE];
need help with this c++ program
#include#include using namespace std; //TODO: Create your struct int main() { const int SIZE = 3; Item inventory[SIZE]; int totalItems = 0, cheapestIndex = 0; double totalValue = 0; for(int i = 0; i < SIZE; i++) { //TODO: Prompt/read item information //adds current item quanitity to total items totalItems += inventory[i].quantity; //adds current item value to total value totalValue += inventory[i].quantity * inventory[i].cost; //keeps track of the cheapest item's index if(inventory[cheapestIndex].cost > inventory[i].cost) cheapestIndex = i; cout << endl << endl; } //TODO: output the total number of inventory items, // the total cost of all the items, and the cheapest item. return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
