Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: Write a class named RetialItem that holds data aobut an item in a retai

ID: 3634800 • Letter: P

Question

Problem:

Write a class named RetialItem that holds data aobut an item in a retail store. The class should have the following member variables: (Description - a string that holds a brief description of the item; UnitsOnHand - An int that holds the number of units currently in inventory; Price - A double that holds the item's retail price.) Write a constructor that accepts arguments for each member variable, appropriate mutator functions that store values in these variables, and accessor functions that return the values in these member variables. Once the class is written, write a separate program that creates three RetialItem objects and stores the following data in them:

Description Units on hand Price
Item#1 Jacket 12 59.95
Item#2 Desinger Jeans 40 34.95
Item#3 Shirt 20 24.95

I do not understand how to even get started on this let alone code the entire thing. I am having problems understanding Classes and OOP. Can anyone help me with this problem? I have to turn it in tomorrow (12/4/11).

Explanation / Answer

please rate - thanks

message me if any problem

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class RetailItem
{public:  
    RetailItem(string, int, double);
    void setDescription(string);
    void setUnitsOnHand(int);
    void setPrice(double);
    string getDescription();
    double getUnitsOnHand();
    double getPrice();
private:
    string description;
    int unitsOnHand;
    double price;
    };
RetailItem::RetailItem(string d, int u, double p)  
{description=d;
unitsOnHand=u;
price=p;
}
double RetailItem::getPrice()
{return price;
}
string RetailItem::getDescription()
{return description;
}
double RetailItem::getUnitsOnHand()
{return unitsOnHand;
}
void RetailItem::setDescription(string d)
{description=d;
}
void RetailItem::setUnitsOnHand(int u)
{unitsOnHand=u;
}
void RetailItem::setPrice(double p)
{price=p;
}  
int main()
{RetailItem a("Jacket",12,59.95);
RetailItem b("Desinger Jeans",40,34.95);
RetailItem c("Shirt",20,24.95);
cout<<"Initial inventory ";
cout<<"Description Units on hand Price ";
cout<<setw(15)<<left<<a.getDescription()<<" "<<a.getUnitsOnHand()<<" "
     <<setprecision(2)<<fixed<<a.getPrice()<<" ";
cout<<setw(15)<<left<<b.getDescription()<<" "<<b.getUnitsOnHand()<<" "
     <<setprecision(2)<<fixed<<b.getPrice()<<" ";
cout<<setw(15)<<left<<c.getDescription()<<" "<<c.getUnitsOnHand()<<" "
     <<setprecision(2)<<fixed<<c.getPrice()<<" ";
a.setUnitsOnHand(2);
b.setPrice(30.00);
c.setDescription("Mens Shirt");
cout<<" Modified Inventory ";
cout<<"Description Units on hand Price ";
cout<<setw(15)<<left<<a.getDescription()<<" "<<a.getUnitsOnHand()<<" "
    <<setprecision(2)<<fixed<<a.getPrice()<<" ";
cout<<setw(15)<<left<<b.getDescription()<<" "<<b.getUnitsOnHand()<<" "
    <<setprecision(2)<<fixed<<b.getPrice()<<" ";
cout<<setw(15)<<left<<c.getDescription()<<" "<<c.getUnitsOnHand()<<" "
    <<setprecision(2)<<fixed<<c.getPrice()<<" ";

system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote