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 technique will NOT help you build rapport with your colleagues?
Ray Of Light [21]

Answer:

I think the answer is "Being consistently unprepared."

Explanation:

hope this helps :)

6 0
3 years ago
Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
Elena L [17]

Answer:

def insSort(arr):

ct=0;

for i in range(1, len(arr)):

key = arr[i]

j = i-1

while j >=0 and key < arr[j] :

arr[j+1] = arr[j]

j -= 1

ct=ct+1;

arr[j+1] = key

return arr,ct;

print(insSort([2,1]))

Output of the program is also attached.

8 0
4 years ago
Value: 3
Citrus2011 [14]

Answer:

B - A word is correctly spelled but is used incorrectly in a document

4 0
3 years ago
What is the database and presentation for files​
Nutka1998 [239]

Answer:

Database Management System ppt DBMS

I don't know if that is right. Sorry if it's not.

6 0
3 years ago
Read 2 more answers
What is the difference between computer architecture and computer organization?
alukav5142 [94]
The distinction between "computer architecture" and "computer organization" has become very fuzzy, if no completely confused or unusable. Computer architecture was essentially a contract with software stating unambiguously what the hardware does. The architecture was essentially a set of statements of the form "If you execute this instruction (or get an interrupt, etc.), then that is what happens. Computer organization, then, was a usually high-level description of the logic, memory, etc, used to implement that contract: These registers, those data paths, this connection to memory, etc. Programs written to run on a particular computer architecture should always run correctly on that architecture no matter what computer organization (implementation) is used. For example, both Intel and AMD processors have the same X86 architecture, but how the two companies implement that architecture (their computer organizations) is usually very different. The same programs run correctly on both, because the architecture is the same, but they may run at different speeds, because the organizations are different. Likewise, the many companies implementing MIPS, or ARM, or other processors are providing the same architecture - the same programs run correctly on all of them - but have very different high - level organizations inside them.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Natural selection is a. how systems of rewards increase desired behaviors. b. the idea that the observable environment affects b
    6·1 answer
  • Como hacer una pagina web
    15·1 answer
  • Every time you are asked to work with others, you are being asked to:
    6·2 answers
  • It is important to ____ the line in the code editing window in the exact location where you want to insert a code snippet to pro
    10·1 answer
  • Write a function named printtriangle that receives a parameter that holds a non-negative integer value and prints a triangle of
    7·1 answer
  • Write a game that plays many rounds of Rock Paper Scissors. The user and computer will each choose between three items: rock (de
    8·1 answer
  • Tiền tệ ra đời là kết quả
    7·2 answers
  • Who is the best nfl team in your mind
    14·2 answers
  • What plugs into this?
    6·2 answers
  • The residual volume can be measured directly with: Select an answer and submit. For keyboard navigation, use the up/down arrow k
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!