Question: I have whitespaces please help me fix. Code: ItemToPurchase.h #ifndef ITEMPURCHASEH #define ITEMPURCHASEH using namespace std; //class Declaration class ItemToPurchase { //declare private variables private:

 I have whitespaces please help me fix. Code: ItemToPurchase.h #ifndef ITEMPURCHASEH

I have whitespaces please help me fix.

Code:

ItemToPurchase.h

#ifndef ITEMPURCHASEH #define ITEMPURCHASEH using namespace std; //class Declaration class ItemToPurchase { //declare private variables private: string itemName; int itemPrice; int itemQuantity; //declare public methods public: //constructor ItemToPurchase(); //methods void SetName(string name); string GetName(); void SetPrice(int price); int GetPrice(); void SetQuantity(int quantity); int GetQuantity(); }; #endif

ItemToPurchase.cpp

#include #include "ItemToPurchase.h" using namespace std; //constructor definition ItemToPurchase::ItemToPurchase():itemName("none"),itemPrice(0),itemQuantity(0){} //method definitions void ItemToPurchase::SetName(string name) { itemName=name; } string ItemToPurchase::GetName() { return itemName; } void ItemToPurchase::SetPrice(int price) { itemPrice=price; } int ItemToPurchase::GetPrice() { return itemPrice; } void ItemToPurchase::SetQuantity(int quantity) { itemQuantity=quantity; } int ItemToPurchase::GetQuantity() { return itemQuantity; }

main.cpp

#include #include "ItemToPurchase.h" using namespace std;

int main() { //declare variables string name; int price; int quantity;

//create two objects of ItemToPurchase class ItemToPurchase item1, item2;

//get item1 details cout > price; cout > quantity;

//call methods and set variables values item1.SetName(name); item1.SetPrice(price); item1.SetQuantity(quantity); cin.ignore();

//get item2 details cout > price; cout > quantity;

//call methods and set variables values item2.SetName(name); item2.SetPrice(price); item2.SetQuantity(quantity);

cout

//calculate item1 and item2 COST int item1_cost = item1.GetQuantity() * item1.GetPrice(); int item2_cost = item2.GetQuantity() * item2.GetPrice();

//calculate total cost int total_cost = item1_cost + item2_cost;

//display item1 and item2 details cout

return 0; }

Enter the 1tem price: Enter the item quantity: Ites. 2 Inter the item name: Enter the item price: Enter the item quantity: TOTAL COST Chocolate Chipg 1 f $3=$3 Bottled Water 10 e $1=$10 Total: $13

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!