SlideShare a Scribd company logo
1 of 6
Download to read offline
#include "stdafx.h"
#include
using namespace std;
class Inventory
{
private:
int itemNumber;
int quantity;
double cost;
double totalCost;
public:
Inventory()
{
itemNumber = 0;
quantity = 0;
cost = 0;
totalCost = 0;
}
Inventory(int newItemNumber, int newQuantity, double newCost)
{
itemNumber = newItemNumber;
quantity = newQuantity;
cost = newCost;
setTotalCost(quantity, cost); // this can be called as quantity and cost have now been
initialized.
}
void setItemNumber(int)
{
itemNumber = itemNumber;
}
void setQuantity(int)
{
quantity = quantity;
}
void setCost(double)
{
cost = cost;
}
void setTotalCost(int, double)
{
totalCost = quantity * cost;
}
int getItemNumber()
{
return itemNumber;
}
int getQuantity()
{
return quantity;
}
double getCost()
{
return cost;
}
double getTotalCost()
{
return totalCost;
}
};
int main()
{
int itemNumber;
int quantity;
double cost;
double totalCost;
cout << "Enter the Item Number: ";
cin >> itemNumber;
while (itemNumber < 0)
{
cout << "Please enter a positive value for the Item Number: ";
cin >> itemNumber;
}
cout << "Enter the Quantity of the item: ";
cin >> quantity;
while (quantity < 0)
{
cout << "Please enter a positive value for the Quantity of the item: ";
cin >> quantity;
}
cout << "Enter the Cost of the item: ";
cin >> cost;
while (cost < 0)
{
cout << "Please enter a positive value for the Cost of the item: ";
cin >> cost;
}
Inventory information(itemNumber, quantity, cost);
totalCost = information.getTotalCost();
itemNumber = information.getItemNumber();
cost = information.getCost();
quantity = information.getQuantity();
cout << "The Item Number is: " << itemNumber << endl;
cout << "The Quantity is: " << quantity << endl;
cout << "The Cost is: " << cost << endl;
cout << "The Total Cost is: " << totalCost << endl;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Solution
#include "stdafx.h"
#include
using namespace std;
class Inventory
{
private:
int itemNumber;
int quantity;
double cost;
double totalCost;
public:
Inventory()
{
itemNumber = 0;
quantity = 0;
cost = 0;
totalCost = 0;
}
Inventory(int newItemNumber, int newQuantity, double newCost)
{
itemNumber = newItemNumber;
quantity = newQuantity;
cost = newCost;
setTotalCost(quantity, cost); // this can be called as quantity and cost have now been
initialized.
}
void setItemNumber(int)
{
itemNumber = itemNumber;
}
void setQuantity(int)
{
quantity = quantity;
}
void setCost(double)
{
cost = cost;
}
void setTotalCost(int, double)
{
totalCost = quantity * cost;
}
int getItemNumber()
{
return itemNumber;
}
int getQuantity()
{
return quantity;
}
double getCost()
{
return cost;
}
double getTotalCost()
{
return totalCost;
}
};
int main()
{
int itemNumber;
int quantity;
double cost;
double totalCost;
cout << "Enter the Item Number: ";
cin >> itemNumber;
while (itemNumber < 0)
{
cout << "Please enter a positive value for the Item Number: ";
cin >> itemNumber;
}
cout << "Enter the Quantity of the item: ";
cin >> quantity;
while (quantity < 0)
{
cout << "Please enter a positive value for the Quantity of the item: ";
cin >> quantity;
}
cout << "Enter the Cost of the item: ";
cin >> cost;
while (cost < 0)
{
cout << "Please enter a positive value for the Cost of the item: ";
cin >> cost;
}
Inventory information(itemNumber, quantity, cost);
totalCost = information.getTotalCost();
itemNumber = information.getItemNumber();
cost = information.getCost();
quantity = information.getQuantity();
cout << "The Item Number is: " << itemNumber << endl;
cout << "The Quantity is: " << quantity << endl;
cout << "The Cost is: " << cost << endl;
cout << "The Total Cost is: " << totalCost << endl;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

More Related Content

Similar to #include stdafx.h#include iostreamusing namespace std;cl.pdf

template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdfashokadyes
 
I have created a class hasdhedDictionary that implements the Diction.pdf
I have created a class hasdhedDictionary that implements the Diction.pdfI have created a class hasdhedDictionary that implements the Diction.pdf
I have created a class hasdhedDictionary that implements the Diction.pdfallystraders
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfinfo334223
 
Need help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docxNeed help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docxLucasmHKChapmant
 
Given main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfGiven main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfillyasraja7
 
Infinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtilInfinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtilInfinum
 
Create a Dynamic Array container with this user interface Ge.pdf
Create a Dynamic Array container with this user interface  Ge.pdfCreate a Dynamic Array container with this user interface  Ge.pdf
Create a Dynamic Array container with this user interface Ge.pdfsktambifortune
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfmail931892
 
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdfBANSALANKIT1077
 
Character.cpphpp givenCharacter.cpp#include Character.hp.pdf
Character.cpphpp givenCharacter.cpp#include Character.hp.pdfCharacter.cpphpp givenCharacter.cpp#include Character.hp.pdf
Character.cpphpp givenCharacter.cpp#include Character.hp.pdftxkev
 
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxvectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxVivekSharma34623
 
Help explain the code with line comments public class CompletedLis.pdf
Help explain the code with line comments public class CompletedLis.pdfHelp explain the code with line comments public class CompletedLis.pdf
Help explain the code with line comments public class CompletedLis.pdfalmonardfans
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdffathimafancyjeweller
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Daniel Pokusa
 
I keep getting an error about m_pHead in printStoresInfo(); function.pdf
I keep getting an error about m_pHead in printStoresInfo(); function.pdfI keep getting an error about m_pHead in printStoresInfo(); function.pdf
I keep getting an error about m_pHead in printStoresInfo(); function.pdfflashfashioncasualwe
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfarorastores
 
For the code below complete the preOrder() method so that it perform.pdf
For the code below complete the preOrder() method so that it perform.pdfFor the code below complete the preOrder() method so that it perform.pdf
For the code below complete the preOrder() method so that it perform.pdfxlynettalampleyxc
 
Given an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdfGiven an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdfMattCu9Parrd
 

Similar to #include stdafx.h#include iostreamusing namespace std;cl.pdf (20)

template-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdftemplate-typename T- class Array { public- ---------------------------.pdf
template-typename T- class Array { public- ---------------------------.pdf
 
I have created a class hasdhedDictionary that implements the Diction.pdf
I have created a class hasdhedDictionary that implements the Diction.pdfI have created a class hasdhedDictionary that implements the Diction.pdf
I have created a class hasdhedDictionary that implements the Diction.pdf
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
Need help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docxNeed help with writing the test cases for the following code in java-.docx
Need help with writing the test cases for the following code in java-.docx
 
Given main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdfGiven main() in the Inventory class, define an insertAtFront() metho.pdf
Given main() in the Inventory class, define an insertAtFront() metho.pdf
 
Infinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtilInfinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtil
 
Create a Dynamic Array container with this user interface Ge.pdf
Create a Dynamic Array container with this user interface  Ge.pdfCreate a Dynamic Array container with this user interface  Ge.pdf
Create a Dynamic Array container with this user interface Ge.pdf
 
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdfHow do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
How do I fix it in LinkedList.javaLabProgram.javaLinkedList.jav.pdf
 
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
#include -algorithm- #include -cstdlib- #include -iostream- #include -.pdf
 
Character.cpphpp givenCharacter.cpp#include Character.hp.pdf
Character.cpphpp givenCharacter.cpp#include Character.hp.pdfCharacter.cpphpp givenCharacter.cpp#include Character.hp.pdf
Character.cpphpp givenCharacter.cpp#include Character.hp.pdf
 
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptxvectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
vectors.(join ALL INDIA POLYTECHNIC (AICTE)).pptx
 
Help explain the code with line comments public class CompletedLis.pdf
Help explain the code with line comments public class CompletedLis.pdfHelp explain the code with line comments public class CompletedLis.pdf
Help explain the code with line comments public class CompletedLis.pdf
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!
 
I keep getting an error about m_pHead in printStoresInfo(); function.pdf
I keep getting an error about m_pHead in printStoresInfo(); function.pdfI keep getting an error about m_pHead in printStoresInfo(); function.pdf
I keep getting an error about m_pHead in printStoresInfo(); function.pdf
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
For the code below complete the preOrder() method so that it perform.pdf
For the code below complete the preOrder() method so that it perform.pdfFor the code below complete the preOrder() method so that it perform.pdf
For the code below complete the preOrder() method so that it perform.pdf
 
Given an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdfGiven an array nums of size n- return the majority element- The majori.pdf
Given an array nums of size n- return the majority element- The majori.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 

More from aashwini4

1. True2. TrueSolution1. True2. True.pdf
1. True2. TrueSolution1. True2. True.pdf1. True2. TrueSolution1. True2. True.pdf
1. True2. TrueSolution1. True2. True.pdfaashwini4
 
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdfaashwini4
 
OH component .pdf
                     OH component                                     .pdf                     OH component                                     .pdf
OH component .pdfaashwini4
 
moles of Na2CO3 = massmolecular mass = 0.50106 .pdf
                     moles of Na2CO3 = massmolecular mass = 0.50106 .pdf                     moles of Na2CO3 = massmolecular mass = 0.50106 .pdf
moles of Na2CO3 = massmolecular mass = 0.50106 .pdfaashwini4
 
Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf
                     Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf                     Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf
Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdfaashwini4
 
E.moles of solute per liter of of solution .pdf
                     E.moles of solute per liter of of solution       .pdf                     E.moles of solute per liter of of solution       .pdf
E.moles of solute per liter of of solution .pdfaashwini4
 
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdfaashwini4
 
We are generally omitt the concentration of the solids &the concentr.pdf
We are generally omitt the concentration of the solids &the concentr.pdfWe are generally omitt the concentration of the solids &the concentr.pdf
We are generally omitt the concentration of the solids &the concentr.pdfaashwini4
 
COVALENT ionic hydrogen bonding .pdf
                     COVALENT ionic hydrogen bonding                  .pdf                     COVALENT ionic hydrogen bonding                  .pdf
COVALENT ionic hydrogen bonding .pdfaashwini4
 
The reaction is maintained at a low temperature with slow addition o.pdf
The reaction is maintained at a low temperature with slow addition o.pdfThe reaction is maintained at a low temperature with slow addition o.pdf
The reaction is maintained at a low temperature with slow addition o.pdfaashwini4
 
There are two reasons.1. Presence of natural immunity2. Immunity.pdf
There are two reasons.1. Presence of natural immunity2. Immunity.pdfThere are two reasons.1. Presence of natural immunity2. Immunity.pdf
There are two reasons.1. Presence of natural immunity2. Immunity.pdfaashwini4
 
The difference between maximization of value of the corporation and .pdf
The difference between maximization of value of the corporation and .pdfThe difference between maximization of value of the corporation and .pdf
The difference between maximization of value of the corporation and .pdfaashwini4
 
The changes between the steady state.SolutionThe changes betwe.pdf
The changes between the steady state.SolutionThe changes betwe.pdfThe changes between the steady state.SolutionThe changes betwe.pdf
The changes between the steady state.SolutionThe changes betwe.pdfaashwini4
 
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdf
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdfSpore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdf
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdfaashwini4
 
b) the solutes volatilize at different rates in t.pdf
                     b) the solutes volatilize at different rates in t.pdf                     b) the solutes volatilize at different rates in t.pdf
b) the solutes volatilize at different rates in t.pdfaashwini4
 
Partnership Firms are taxed at multiple levels the Corporate Level.pdf
Partnership Firms are taxed at multiple levels  the Corporate Level.pdfPartnership Firms are taxed at multiple levels  the Corporate Level.pdf
Partnership Firms are taxed at multiple levels the Corporate Level.pdfaashwini4
 
Please give the problem detailsWhat are the solutions being mixed.pdf
Please give the problem detailsWhat are the solutions being mixed.pdfPlease give the problem detailsWhat are the solutions being mixed.pdf
Please give the problem detailsWhat are the solutions being mixed.pdfaashwini4
 
One case of paternity testing has been given in the figure. Four aut.pdf
One case of paternity testing has been given in the figure. Four aut.pdfOne case of paternity testing has been given in the figure. Four aut.pdf
One case of paternity testing has been given in the figure. Four aut.pdfaashwini4
 
Answer is D. I (1) will add at the carbonyl rath.pdf
                     Answer is D.  I (1) will add at the carbonyl rath.pdf                     Answer is D.  I (1) will add at the carbonyl rath.pdf
Answer is D. I (1) will add at the carbonyl rath.pdfaashwini4
 
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdf
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdfNasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdf
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdfaashwini4
 

More from aashwini4 (20)

1. True2. TrueSolution1. True2. True.pdf
1. True2. TrueSolution1. True2. True.pdf1. True2. TrueSolution1. True2. True.pdf
1. True2. TrueSolution1. True2. True.pdf
 
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf
1. Seminal vesicle2. Prostate gland3. bulbourethral gland4. Ep.pdf
 
OH component .pdf
                     OH component                                     .pdf                     OH component                                     .pdf
OH component .pdf
 
moles of Na2CO3 = massmolecular mass = 0.50106 .pdf
                     moles of Na2CO3 = massmolecular mass = 0.50106 .pdf                     moles of Na2CO3 = massmolecular mass = 0.50106 .pdf
moles of Na2CO3 = massmolecular mass = 0.50106 .pdf
 
Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf
                     Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf                     Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf
Hydronium ion = hydrogen ion [H3O+] = [H+] = 2.15.pdf
 
E.moles of solute per liter of of solution .pdf
                     E.moles of solute per liter of of solution       .pdf                     E.moles of solute per liter of of solution       .pdf
E.moles of solute per liter of of solution .pdf
 
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf
   This is mainly based on Hard - Soft acid base theory.Hard Acid .pdf
 
We are generally omitt the concentration of the solids &the concentr.pdf
We are generally omitt the concentration of the solids &the concentr.pdfWe are generally omitt the concentration of the solids &the concentr.pdf
We are generally omitt the concentration of the solids &the concentr.pdf
 
COVALENT ionic hydrogen bonding .pdf
                     COVALENT ionic hydrogen bonding                  .pdf                     COVALENT ionic hydrogen bonding                  .pdf
COVALENT ionic hydrogen bonding .pdf
 
The reaction is maintained at a low temperature with slow addition o.pdf
The reaction is maintained at a low temperature with slow addition o.pdfThe reaction is maintained at a low temperature with slow addition o.pdf
The reaction is maintained at a low temperature with slow addition o.pdf
 
There are two reasons.1. Presence of natural immunity2. Immunity.pdf
There are two reasons.1. Presence of natural immunity2. Immunity.pdfThere are two reasons.1. Presence of natural immunity2. Immunity.pdf
There are two reasons.1. Presence of natural immunity2. Immunity.pdf
 
The difference between maximization of value of the corporation and .pdf
The difference between maximization of value of the corporation and .pdfThe difference between maximization of value of the corporation and .pdf
The difference between maximization of value of the corporation and .pdf
 
The changes between the steady state.SolutionThe changes betwe.pdf
The changes between the steady state.SolutionThe changes betwe.pdfThe changes between the steady state.SolutionThe changes betwe.pdf
The changes between the steady state.SolutionThe changes betwe.pdf
 
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdf
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdfSpore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdf
Spore forming bacteria (prokaryotes) such as Bacillus anthracis can .pdf
 
b) the solutes volatilize at different rates in t.pdf
                     b) the solutes volatilize at different rates in t.pdf                     b) the solutes volatilize at different rates in t.pdf
b) the solutes volatilize at different rates in t.pdf
 
Partnership Firms are taxed at multiple levels the Corporate Level.pdf
Partnership Firms are taxed at multiple levels  the Corporate Level.pdfPartnership Firms are taxed at multiple levels  the Corporate Level.pdf
Partnership Firms are taxed at multiple levels the Corporate Level.pdf
 
Please give the problem detailsWhat are the solutions being mixed.pdf
Please give the problem detailsWhat are the solutions being mixed.pdfPlease give the problem detailsWhat are the solutions being mixed.pdf
Please give the problem detailsWhat are the solutions being mixed.pdf
 
One case of paternity testing has been given in the figure. Four aut.pdf
One case of paternity testing has been given in the figure. Four aut.pdfOne case of paternity testing has been given in the figure. Four aut.pdf
One case of paternity testing has been given in the figure. Four aut.pdf
 
Answer is D. I (1) will add at the carbonyl rath.pdf
                     Answer is D.  I (1) will add at the carbonyl rath.pdf                     Answer is D.  I (1) will add at the carbonyl rath.pdf
Answer is D. I (1) will add at the carbonyl rath.pdf
 
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdf
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdfNasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdf
Nasal cavity( nasal mucosa)-In humans, olfaction occurs when odora.pdf
 

Recently uploaded

e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

#include stdafx.h#include iostreamusing namespace std;cl.pdf

  • 1. #include "stdafx.h" #include using namespace std; class Inventory { private: int itemNumber; int quantity; double cost; double totalCost; public: Inventory() { itemNumber = 0; quantity = 0; cost = 0; totalCost = 0; } Inventory(int newItemNumber, int newQuantity, double newCost) { itemNumber = newItemNumber; quantity = newQuantity; cost = newCost; setTotalCost(quantity, cost); // this can be called as quantity and cost have now been initialized. } void setItemNumber(int) { itemNumber = itemNumber; } void setQuantity(int) { quantity = quantity; } void setCost(double)
  • 2. { cost = cost; } void setTotalCost(int, double) { totalCost = quantity * cost; } int getItemNumber() { return itemNumber; } int getQuantity() { return quantity; } double getCost() { return cost; } double getTotalCost() { return totalCost; } }; int main() { int itemNumber; int quantity; double cost; double totalCost; cout << "Enter the Item Number: "; cin >> itemNumber; while (itemNumber < 0) { cout << "Please enter a positive value for the Item Number: "; cin >> itemNumber;
  • 3. } cout << "Enter the Quantity of the item: "; cin >> quantity; while (quantity < 0) { cout << "Please enter a positive value for the Quantity of the item: "; cin >> quantity; } cout << "Enter the Cost of the item: "; cin >> cost; while (cost < 0) { cout << "Please enter a positive value for the Cost of the item: "; cin >> cost; } Inventory information(itemNumber, quantity, cost); totalCost = information.getTotalCost(); itemNumber = information.getItemNumber(); cost = information.getCost(); quantity = information.getQuantity(); cout << "The Item Number is: " << itemNumber << endl; cout << "The Quantity is: " << quantity << endl; cout << "The Cost is: " << cost << endl; cout << "The Total Cost is: " << totalCost << endl; return 0; } int _tmain(int argc, _TCHAR* argv[]) { return 0; } Solution #include "stdafx.h" #include
  • 4. using namespace std; class Inventory { private: int itemNumber; int quantity; double cost; double totalCost; public: Inventory() { itemNumber = 0; quantity = 0; cost = 0; totalCost = 0; } Inventory(int newItemNumber, int newQuantity, double newCost) { itemNumber = newItemNumber; quantity = newQuantity; cost = newCost; setTotalCost(quantity, cost); // this can be called as quantity and cost have now been initialized. } void setItemNumber(int) { itemNumber = itemNumber; } void setQuantity(int) { quantity = quantity; } void setCost(double) { cost = cost; }
  • 5. void setTotalCost(int, double) { totalCost = quantity * cost; } int getItemNumber() { return itemNumber; } int getQuantity() { return quantity; } double getCost() { return cost; } double getTotalCost() { return totalCost; } }; int main() { int itemNumber; int quantity; double cost; double totalCost; cout << "Enter the Item Number: "; cin >> itemNumber; while (itemNumber < 0) { cout << "Please enter a positive value for the Item Number: "; cin >> itemNumber; } cout << "Enter the Quantity of the item: "; cin >> quantity;
  • 6. while (quantity < 0) { cout << "Please enter a positive value for the Quantity of the item: "; cin >> quantity; } cout << "Enter the Cost of the item: "; cin >> cost; while (cost < 0) { cout << "Please enter a positive value for the Cost of the item: "; cin >> cost; } Inventory information(itemNumber, quantity, cost); totalCost = information.getTotalCost(); itemNumber = information.getItemNumber(); cost = information.getCost(); quantity = information.getQuantity(); cout << "The Item Number is: " << itemNumber << endl; cout << "The Quantity is: " << quantity << endl; cout << "The Cost is: " << cost << endl; cout << "The Total Cost is: " << totalCost << endl; return 0; } int _tmain(int argc, _TCHAR* argv[]) { return 0; }