1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Black_prince [1.1K]
3 years ago
15

30.1 LAB*: Warm up: Online shopping cart (Part 1) (1) Create three files to submit: ItemToPurchase.h - Class declaration ItemToP

urchase.cpp - Class definition main.cpp - main() function Build the ItemToPurchase class with the following specifications: Default constructor Public class functions (mutators & accessors) SetName() & GetName() (2 pts) SetPrice() & GetPrice() (2 pts) SetQuantity() & GetQuantity() (2 pts) 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 main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call cin.ignore() to allow the user to input a new string. (2 pts)

Computers and Technology
1 answer:
nlexa [21]3 years ago
3 0

Answer:

see explaination

Explanation:

#ifndef ITEMTOPURCHASE_H

#define ITEMTOPURCHASE_H

#include<iostream>

using namespace std;

class ItemToPurchase

{

public:

ItemToPurchase();

void setItemName(string name);

void setItemPrice(int itemPrice);

void setItemQuantity(int itemQuantity);

string getItemName();

int getItemPrice();

int getItemQuantity();

virtual ~ItemToPurchase();

protected:

private:

string itemName ;

int itemPrice;

int itemQuantity ;

};

#endif // ITEMTOPURCHASE_H

#include "ItemToPurchase.h"

ItemToPurchase::ItemToPurchase()

{

//ctor

this->itemName="none";

this->itemPrice=0;

this->itemQuantity=0;

}

void ItemToPurchase::setItemName(string name)

{

this->itemName=name;

}

void ItemToPurchase::setItemPrice(int itemPrice)

{

this->itemPrice=itemPrice;

}

void ItemToPurchase::setItemQuantity(int itemQuantity)

{

this->itemQuantity=itemQuantity;

}

string ItemToPurchase::getItemName()

{

return itemName;

}

int ItemToPurchase::getItemPrice()

{

return itemPrice;

}

int ItemToPurchase::getItemQuantity()

{

return itemQuantity;

}

ItemToPurchase::~ItemToPurchase()

{

//dtor

}

#include <iostream>

#include "ItemToPurchase.h"

using namespace std;

int main()

{

ItemToPurchase item1,item2;

string itemName ;

int itemPrice;

int itemQuantity ;

int totalCost=0;

cout<<"Item 1:"<<endl;

cout<<"Enter the item name : ";

getline(cin,itemName);

//cin.ignore();

cout<<"Enter the item price : ";

cin>>itemPrice;

cout<<"Enter the item quantity : ";

cin>>itemQuantity;

item1.setItemName(itemName);

item1.setItemPrice(itemPrice);

item1.setItemQuantity(itemQuantity);

cin.ignore();

cout<<"Item 2:"<<endl;

cout<<"Enter the item name : ";

getline(cin,itemName);

//cin.ignore();

cout<<"Enter the item price : ";

cin>>itemPrice;

cout<<"Enter the item quantity : ";

cin>>itemQuantity;

item2.setItemName(itemName);

item2.setItemPrice(itemPrice);

item2.setItemQuantity(itemQuantity);

cout<<"TOTAL COST : "<<endl;

cout<<item1.getItemName()<<" "<<item1.getItemQuantity()<<" at $"<<item1.getItemPrice()<<" = "<<(item1.getItemQuantity()*item1.getItemPrice())<<endl;

cout<<item2.getItemName()<<" "<<item2.getItemQuantity()<<" at $"<<item2.getItemPrice()<<" = "<<(item2.getItemQuantity()*item2.getItemPrice())<<endl;

totalCost=(item1.getItemQuantity()*item1.getItemPrice())+(item2.getItemQuantity()*item2.getItemPrice());

cout<<"Total : $"<<totalCost<<endl;

return 0;

}

Note: Replace at with the at symbol

See attachment for output

You might be interested in
Which structure is sometimes called the "gateway to memory"?
balu736 [363]
The answer is, hippocampus
 

The hippocampus is involved in the initial stages of memory, especially for spatial memory and for the memory of facts and experiences.

hope this helps <3
3 0
3 years ago
Why do most programmers indent the conditionally executed statements in a decision structure?
Digiron [165]
It visually groups the statements that belong together, and allows you to quickly see the flow of a program by looking at the indents.
7 0
4 years ago
A beginning driver may tend to oversteer. This means the driver what? Btw Cars are technology so that is why it is under Compute
Nataliya [291]
<span> have a tendency to turn more sharply than was intended</span>
8 0
3 years ago
Bradley is working on a program that uses different classes in specific relationships. Help him remember what these relationship
Kitty [74]

Answer:

First one is INHERITANCE. Second one is AGGREGATION.

3 0
3 years ago
"bing ads keyword planner allows you to search for new keywords using a phrase, website, or category. from which bing ads tabs c
MrRissso [65]
<span>The navigation is very simple

1.On the top menu, click Tools -> click Keyword Planner.

2.Then you can click Search for new keywords using a phrase, website, or category.

In case if you want to multiply key word list to get new keywords, follow below steps.

1.On the top menu, click Tools -> click Keyword Planner.

2.Click Multiply keyword lists to get new keywords.</span>
8 0
4 years ago
Other questions:
  • PYTHON CODE ONLY:
    7·1 answer
  • Which statement about information published on the internet is true?
    9·2 answers
  • What channel will the republian debate be broadcast on?
    6·2 answers
  • The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
    12·1 answer
  • Write a short assembly language program in either our 8088 SCO DOSBox or 80386+ MASM Visual Studio 2017 environment that demonst
    11·1 answer
  • Resumen sobres el correo electrónico​
    6·1 answer
  • Differentiate agricultural waste from hazardous waste.​
    9·1 answer
  • Which of the following are NOT possible using the RANDOM(a, b) and DISPLAY(expression) abstractions?
    10·1 answer
  • ICT Practical Work
    12·1 answer
  • Write a program that computes how much each person in a group needs to pay (after tax and tip) when splitting the bill equally.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!