Question

Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data about

Sample Output: CA. C:\WINDOWS\system32\cmd.exe Enter description for item 1: paper Enter price for item 1: 4.99 Enter quantit

C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// RetailItem.h

#ifndef RETAILITEM_H
#define RETAILITEM_H

class RetailItem
{
public:
RetailItem();
string getDescription();
int getQuantity();
double getPrice();
  
void setDescription(string desc);
void setQuantity(int qty);
void setPrice(int price);
private:
// Declaring variables
double price;
int quantity;
string description;
};
#endif

=====================================

// RetailItem.cpp

#include <iostream>
using namespace std;
#include "RetailItem.h"


RetailItem::RetailItem()
{
this->description="none";
this->quantity=0;
this->price=0;
}
string RetailItem::getDescription()
{
return description;
}
int RetailItem::getQuantity()
{
return quantity;
}
double RetailItem::getPrice()
{
return price;
}
  
void RetailItem::setDescription(string desc)
{
this->description=desc;
}
void RetailItem::setQuantity(int qty)
{
this->quantity=qty;
}
void RetailItem::setPrice(int price)
{
this->price=price;
}

======================================

// Store.h

#ifndef STORE_H
#define STORE_H

#include "RetailItem.h"

class Store
{
public:
Store(int num=5);
void displayAllItems();
int getNumItems();
string getStoreName();
void setAllItems();
void setStoreName(string name);
  
private:
// Declaring variables
RetailItem *items;
string storeName;
int numItems;
};
#endif

=========================================

// Store.cpp

#include <iostream>
#include <iomanip>
using namespace std;
#include "Store.h"


Store::Store(int num)
{

this->numItems=num;
this->items=new RetailItem[num];
}
void Store::displayAllItems()
{
cout<<storeName<<endl;
cout<<numItems<<" items in stock"<<endl;
cout<<setw(20)<<left<<"Description"<<setw(10)<<left<<"Price"<<setw(10)<<left<<"Quantity"<<endl;
for(int i=0;i<45;i++)
{
cout<<"*";
}
cout<<endl;
  
for(int i=0;i<numItems;i++)
{
cout<<setw(20)<<left<<items[i].getDescription()<<setw(10)<<left<<items[i].getPrice()<<setw(10)<<left<<items[i].getQuantity()<<endl;
}
}
int Store::getNumItems()
{
return numItems;
}
string Store::getStoreName()
{
return storeName;
}
void Store::setAllItems()
{
string desc;
double price;
int qty;
for(int i=0;i<numItems;i++)
{
cout<<"Enter description for item "<<(i+1)<<":";
getline(cin,desc);
items[i].setDescription(desc);
cout<<"Enter price for item "<<(i+1)<<":";
cin>>price;
items[i].setPrice(price);
cout<<"Enter quantity for item "<<(i+1)<<":";
cin>>qty;
items[i].setQuantity(qty);
cin.ignore();
}
}
  
void Store::setStoreName(string name)
{
this->storeName=name;
}

=========================================

// main.cpp

#include <iostream>
using namespace std;
#include "Store.h"

int main()
{
Store s;
s.setStoreName("Webster Grocery");
s.setAllItems();
s.displayAllItems();

return 0;
}

========================================

output:

1 ./Retailltem Enter description for item 1: paper, Enter price for item 1:4.99 Enter quantity for item 1:120 Enter_descripti

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and...

    Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and a driver program called invoiceDriver.cpp. The class Invoice is used in a hardware store to represent an invoice for an item sold at the store. An invoice class should include the following: A part number of type string A part description of type string A quantity of the item being purchased of type int A price per item of type int A class constructor...

  • Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console...

    Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named Retailltem and should hold data about an item in a retail store. The class will have the following member variables. Description- string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that...

    Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named RetailItem and should hold data about an item in a retail store. The class will have the following member variables. Description - string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the item...

  • USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds...

    USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about 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 thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...

  • 4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping...

    4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (solution from previous lab assignment is provided in Canvas). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal PrintItemDescription() -...

  • 8.7 LAB*: Program: Online shopping cart (Part 2)

    8.7 LAB*: Program: Online shopping cart (Part 2)Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input.This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).(1) Extend the ItemToPurchase class per the following specifications:Private fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • (C++ Program) 1. Write a program to allow user enter an array of structures, with each...

    (C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT