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 #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
main.cpp
#include
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: $13Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started