Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started