Question

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

You will need two constructors, one that will accept arguments for each member variable and one that will assign default values. You will also need to write mutator functions and accessor functions. Once you write the class, write a separate program that creates three RetailItem objects. The first one should use the default values, and the other two should have values assigned upon creation. The user should input the variables (testing for the units on hand and price greater than 0).

Then, the program should display all three RetailItems. Finally, the program should tally the inventory for all three items and display it.

Welcome to the Retail store!

Price must be greater than 0.

Please enter the price for item 1: 33

Inventory must be greater than 0.

Please enter the units on hand for item 1: 10

Please enter the description for item 1: shirt

Display all items

Description: shirt

Units on hand: 10

Price: $33.00

Description: Jeans

Units on hand: 40

Price: $34.95

Description: Long sleeve shirt

Units on hand: 20

Price: $24.95

Display the total inventory.

The total inventory is 70.

Press any key to continue.

Be sure to think about the logic and design first, then code the C++ program.

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

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.

Refer to the screenshot for the file names and structure.

Thank You!


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

#include<iostream>
#include<string>
using namespace std;


class RetailItem{
   private:
       string description;
       int unitsOnHand;
       double price;
   public:
       RetailItem();
       RetailItem(string,int, double);
       void setDescription(string);
       void setUnits(int);
       void setPrice(double);
       string getDescription() const;
       int getUnits() const;
       double getPrice() const;
};

RetailItem::RetailItem(){description="Jean";unitsOnHand=40;price=34.95;
}
RetailItem::RetailItem(string desc , int units, double prices){
   description=desc;
   unitsOnHand = units;
   price=prices;
}
void RetailItem::setDescription(string desc){
   description = desc;
}
void RetailItem::setUnits(int units){
   unitsOnHand = units;
}
void RetailItem::setPrice(double prices){
   price=prices;
}
string RetailItem::getDescription() const{return description;}
int RetailItem::getUnits() const{return unitsOnHand;}
double RetailItem::getPrice() const{return price;}

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

#include<iostream>
#include<string>
#include "RetailItem.cpp"

using namespace std;

int main(){

   RetailItem items[3];
   items[2].setDescription("Long sleeve shirt");
   items[2].setUnits(20);
   items[2].setPrice(24.95);
   cout<<"Welcome to the Retail store!\n";
   int units=0;double price;
       do{
       cout<<"Price must be greater than 0.\n";
       cout<<"Please enter the price for item 1: ";
       cin>>price;
   }while(price<=0);
   do{
       cout<<"Inventory must be greater than 0.\n";
       cout<<"Please enter the units on hand for item 1: ";
       cin>>units;
   }while(units<=0);
   string desc;
   cout<<"Please enter the description for item 1: "; cin>>desc;
  
   items[0].setDescription("Long sleeve shirt");
   items[0].setUnits(units);
   items[0].setPrice(price);
  
   cout<<"\n\nDisplaying all items\n\n";
   int totalInventory=0;
   for(int i=0; i<3; i++){
       cout<<"Description: "<<items[i].getDescription()<<endl;
       cout<<"Units on hand: "<<items[i].getUnits()<<endl;
       cout<<"Price: $"<<items[i].getPrice()<<endl;
       totalInventory+=items[i].getUnits();
   }
   cout<<"\nDisplay the total inventory\n";
   cout<<"the total inventory is "<<totalInventory<<endl;


   return 0;
}

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

Retailltem.cpp RIM.cpp 1 #include<iostream> 2 #include<string> 3 #include RetailItem.cpp C:\Users\User Documents\RIM.exe We

Add a comment
Know the answer?
Add Answer to:
Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that...
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
  • 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...

  • 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:...

  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class,...

    Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class, Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields description: The description field is a String object that holds a brief description of the item . unitsOnHand: The unitsOnHand field is an int variable that holds the number of units currently in inventory Price: The price field is a double that...

  • Write a class named RetailItem that holds data about an item in a retail store. The...

    Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description, unit sold, units in inventory, and price. Once you have written the class, write a program that creates 5 RetailItem objects and stores the following data in them: Description Units Sold Units in Inventory Price Item #1 Jacket 20 12 59.95 Item #2 Designer Jeans 150 40 34.95 Item #3 Shirt 230 20 24.95...

  • in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "Ret...

    in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....

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

    C++ Retailltem.h, Retailltem.cpp, Store.h, Store.cpp, and Driver.cpp. Description: Write a set of programs that holds data about items in a retail store. Your submission should include 5 files, Retailltem.b, Retailltem.cpp, Store, Store.cpp, and Driver.cpp 1. Retailltem class: The class should have three member variables • description (a string, represent the item's name. A name contains space) quantity (an int, represent how many current available) price (a double, item's price) Member Functions Constructor with default argument get Description getQuantity getPrice setDescription...

  • in python Write a class named RetaiI_Item that holds data about an item in a retail...

    in python Write a class named RetaiI_Item that holds data about an item in a retail store. The class should store the following data in attributes: • Item Number • Item Description • Units in Inventory • Price Create another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should include the following methods: • A method named purchase_item that accepts a...

  • 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...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

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