Connect with a knowledgeable community and get your questions answered on IDNLearn.com. Our experts are available to provide accurate, comprehensive answers to help you make informed decisions about any topic or issue you encounter.

C++ only!Write code to assign name and density properties to currMat, and store currMat in requestedMaterials. Input first receives a name value, then a density value.Input example: Water 993 Tar 1153 quit -1#include #include #include using namespace std;class Material {public:void SetNameAndDensity(string materialName, int materialDensity) {name = materialName;density = materialDensity;}void PrintMaterial() const {cout << name << " - " << density << endl;}string GetName() const { return name; }int GetDensity() const { return density; }private:string name;int density;};int main() {vector requestedMaterials;Material currMat;string currName;int currDensity;unsigned int i;cin >> currName;cin >> currDensity;while ((currName != "quit") && (currDensity > 0)) {/* Your code goes here */cin >> currName;cin >> currDensity;}for (i = 0; i < requestedMaterials.size(); ++i) {currMat = requestedMaterials.at(i);currMat.PrintMaterial();}return 0;}

Sagot :

Your presence in our community is highly appreciated. Keep sharing your insights and solutions. Together, we can build a rich and valuable knowledge resource for everyone. Find clear and concise answers at IDNLearn.com. Thanks for stopping by, and come back for more dependable solutions.