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

Create three files to submit. 8.13 Programming Assignment #08 (1) Create three f

ID: 3599993 • Letter: C

Question

Create three files to submit.

8.13 Programming Assignment #08 (1) Create three files to submit: . Item ToPurchase.h - Class declaration - temloPurchase.cpp Class detinition main.cpp - main function Build the ItemToPurchase class with the following specifications . Default constructor Public class functions (mutators& accessors) SetName0 & GetName SetPrice0 & GetPrice SetQuantity0) & GetQuantity0 Private data members string itemName - Initialized in default constructor to none int itemPrice-Initialized in default constructor to 0 int itemQuantity-Initialized in default constructor to 0 (2) In main0. prompt the user for two items and create two objects of the Item ToPurchase class. Before prompting for the second item, call cin.ignore0 to allow the user to input a new string Ex: Item 1 Enter the item name: Chocolate Chips Enter the item price: Enter the item quantity: 1 Item 2 Enter the item name: B tt led water Enter the item price: 1 Enter the item quantity:

Explanation / Answer

ItemToPurchase.h file : ----------------------------->>>>>>>>>>>>>>>>>>>

#ifndef _ITEMTOPURCHASE_H
#define _ITEMTOPURCHASE_H
#include<iostream>

using namespace std;
class ItemToPurchase{
   string itemName;
   int itemPrice;
   int itemQuantity;
   public:
   ItemToPurchase();
   void setName(string);
   void setPrice(int);
   void setQuantity(int);
   string getName();
   int getPrice();
   int getQuantity();
};

#endif

ItemToPurchase.cpp file : ------------------------->>>>>>>>>>>>>>>>>>

#include<iostream>
#include "itemtopurchase.h"

using namespace std;

ItemToPurchase::ItemToPurchase(){
itemName = "none";
itemPrice = 0;
itemQuantity = 0;
}
void ItemToPurchase::setName(string n){
itemName = n;
}
void ItemToPurchase::setPrice(int p){
itemPrice = p;
}
void ItemToPurchase::setQuantity(int q){
itemQuantity = q;
}
string ItemToPurchase::getName(){
return itemName;
}
int ItemToPurchase::getPrice(){
return itemPrice;
}
int ItemToPurchase::getQuantity(){
return itemQuantity;
}

main.cpp file : ---------------------------------->>>>>>>>>>>>>>>>>>>>>>>>>>

#include<iostream>
#include "itemToPurchase.cpp"

using namespace std;

int main(){
ItemToPurchase item[2];
string name;
int price;
int quantity;

for(int i = 0;i<2;i++){
  cout<<" Item "<<i+1;
  cout<<" Enter The Item Name ";
  cin>>name;
  cout<<" Enter The Price Of the item ";
  cin>>price;
  cout<<" Enter the quantity of the item ";
  cin>>quantity;
   item[i].setName(name);
   item[i].setPrice(price);
   item[i].setQuantity(quantity);
}
    

cout<<" TOTAL COST ";
for(int i =0 ;i<2;i++){
   cout<<" "<<item[i].getName()<<"   "<<item[i].getQuantity()<<" @   $"<<item[i].getPrice()<<" = "<<(item[i].getPrice()*item[i].getQuantity());
   
  }

cout<<" TOTAL = "<<(item[0].getPrice()*item[1].getQuantity())+(item[0].getPrice()*item[0].getQuantity());
cout<<endl;
   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