Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.23 LAB: Product class Given main() and Producth, define the Product class (in Product cpp) that will manage product inventory Product class has three private

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
2.23 LAB: Product class Given main() and Producth, define the Product class (in Product cpp) that will manage product inventory Product class has three private data membert: a product code (string). The product's price (double), and the number count of product in inventory (int). Implement the following Constructor and member functions listed in the Producth file . Product(string code, double price, int count)- set the data members using the three parameters void SetCode(string code) set the product code (le SKU234) to parameter code string GetCode) - return the product code void SetProe double p) set the price to parameter double GetPriceoretum the price void SetCount(int num) set the number of items in inventory to parameter num Int GetCount) return the count void Addinventory(int omt). Increase inventory by porameter amt void Sellwerdory(int am) decrease inventory by parameter amt Output each floating point value with two digits after the decimal point, which can be achieved by executing cout 2 include 1 #include "Product.h" using namespace std; 7 8 int main() 10 string nane - "Apple", 11 double price - 0.40; 12 int nus - 3 13 14 Product p - Product (name, price, num); 15 16 cout 2. #include 3 #include "Product.h" 4 5 using namespace std; 6 7 double inventoryvalue(); 8): 9 10 InventoryItem:: InventoryItem() { product - **; inventory - e; 13 price - 0.8; 12 15 17 16 InventoryItem:: InventoryItem(string prod, int in double p) product - prod; 18 inventory = in; price - P: 20) 19 Develop mode Submit mode Run your program as often as youd like, before submitting for grading input values in the first box, then click Run program and observe the p File is marked as read only Current file: Product.h Wine CUSC 5 using namespace std; 6 7 class Product 8 10 11 12 13 14 16 12 12 19 20 21 22 23 24 public Product(string, double, int); void set code(string): string Getcode(): void SetPrice(double): double GetPrice(): vold Set count(int): int Get count: void Add Inventory (int) vold Sellinventory (int): private string code, double prices int count: Develop mode Submit mode Run your program as often as you'd like, before submitting for grading Below, type any n input values in the first box, then click Run program and observe the programis output in second box Current file: Product.cpp Loa 26 29 25 void Inventoryitem!: set Inventory(int in) inventory - in; 27 ) 28 vold InventoryItem: setPrice(double p) { price - P: 30) 31 12 string Inventorytem:getProduct() 33 return products 34 ) 35 int Inventoryttom:teet Tnventory return inventory: 37) 38 double InventoryItem: getPrice return prices 40) 41 42 double Inventory testinventoryvalue) return Inventory price: 16 39 Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below input values in the first box, then click Run program and observe the program: second box

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions