Question: Below is the Can class #include #include using namespace std; // Can class class Can { // private variables to store item name and weight

 Below is the Can class #include #include using namespace std; //

Below is the Can class

#include #include using namespace std;

// Can class class Can { // private variables to store item name and weight private: string item; int weight; public: // Constructor Can(string i, int w) { item = i; weight = w; } // method to get name of the item string getItem() { return item; } // method to get weight of the item int getWeight() { return weight; } };

// main int main() { // Creating 4 objects of class Can Can can1("Pepsi", 12); Can can2("pears", 16); Can can3("mustard", 32); Can can4("apple juice", 40);

// variable to store the total weight of everything int totalWeight = 0;

// printing the 4 objects and sum their weights cout

// print the weight of everything cout

return 0; }

1. Separate the Can class into a header file and an implementation file 2. The main function will be in a separate file as well - so you will have 3 files: main.cpp, Can.h, Can.cpp 3. In the main file, you will create an array of Cans with the following items: a. 12 ounce can of Coke b. 16 ounce can of Mango Monster Energy Drink c. 8 ounce can of Red Bull d. 16 ounce can of Bang! e. 16 ounce can of Venom Energy f. 12 ounce can of Jolt Cola 4. Write a function in main program that passes the array of Cans, prints the contents and weight of each can and then prints the total weight of all cans

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!