SlideShare a Scribd company logo
1 of 3
Download to read offline
#include
#include
#include
using namespace std;
class DivSales {
private:
static double corpSales;
double divSales;
public:
double qtrs[4];
DivSales() {
divSales = 0.0;
for (int i = 0; i < 4; i++) {
qtrs[i] = 0.0;
}
}
void setDivSales(double s) {
divSales = s;
corpSales += s;
}
double getDivSales() const {
return divSales;
}
double getTotalSales() const {
double total = 0.0;
for (int i = 0; i < 4; i++) {
total += qtrs[i];
}
return total;
}
static double getCorpSales() {
return corpSales;
}
friend istream& operator>>(istream& in, DivSales& ds) {
double s;
for (int i = 0; i < 4; i++) {
in >> s;
ds.qtrs[i] = s;
ds.divSales += s;
corpSales += s;
}
return in;
}
};
double DivSales::corpSales = 0.0;
int main() {
const int NUM_DIVISIONS = 6;
DivSales divisions[NUM_DIVISIONS];
ifstream infile("SalesFile.txt");
for (int i = 0; i < NUM_DIVISIONS; i++) {
infile >> divisions[i];
}
int divisionNumber;
bool quit = false; // Flag to control the loop
while (!quit) {
cout << "Enter division number (1-6), or 0 to quit: ";
cin >> divisionNumber;
if (divisionNumber == 0) {
quit = true; // Set the flag to true to exit the loop
} else if (divisionNumber < 1 || divisionNumber > NUM_DIVISIONS) {
cout << "Invalid division number. Try again.n";
} else {
const int divisionIndex = divisionNumber - 1;
cout << "Sales for division " << divisionNumber << ":n";
for (int i = 0; i < 4; i++) {
cout << "Division #" << divisionNumber << "tQuarter " << (i + 1) << ": $" << fixed
<< setprecision(2) << divisions[divisionIndex].qtrs[i] << "n";
}
cout << "Division #" << divisionNumber << " total sales are: $" << fixed <<
setprecision(2) << divisions[divisionIndex].getTotalSales() << "n";
}
}
cout << "Total corporation sales: $" << fixed << setprecision(2) << DivSales::getCorpSales()
<< "n";
return 0;
}
How to prepare a test case/Multiple Test Cases document of the above program?

More Related Content

Similar to #include iostream#include iomanip#include fstreamusing n.pdf

So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
arjuncollection
 
Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your code
vmandrychenko
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
aathiauto
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
s2team
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
MongoDB
 

Similar to #include iostream#include iomanip#include fstreamusing n.pdf (20)

テストデータどうしてますか?
テストデータどうしてますか?テストデータどうしてますか?
テストデータどうしてますか?
 
Mythbusting: Understanding How We Measure Performance at MongoDB
Mythbusting: Understanding How We Measure Performance at MongoDBMythbusting: Understanding How We Measure Performance at MongoDB
Mythbusting: Understanding How We Measure Performance at MongoDB
 
So I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdfSo I already have most of the code and now I have to1. create an .pdf
So I already have most of the code and now I have to1. create an .pdf
 
Practices For Becoming A Better Programmer
Practices For Becoming A Better ProgrammerPractices For Becoming A Better Programmer
Practices For Becoming A Better Programmer
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScript
 
Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your code
 
DBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たちDBIx::Skinnyと仲間たち
DBIx::Skinnyと仲間たち
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
C++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical ReviewerC++ Code as Seen by a Hypercritical Reviewer
C++ Code as Seen by a Hypercritical Reviewer
 
program#include iostreamusing namespace std;void calculatio.pdf
program#include iostreamusing namespace std;void calculatio.pdfprogram#include iostreamusing namespace std;void calculatio.pdf
program#include iostreamusing namespace std;void calculatio.pdf
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 
Clean up your code with C#6
Clean up your code with C#6Clean up your code with C#6
Clean up your code with C#6
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
All you need to know about JavaScript Functions
All you need to know about JavaScript FunctionsAll you need to know about JavaScript Functions
All you need to know about JavaScript Functions
 
Refactoring
RefactoringRefactoring
Refactoring
 
Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 

More from srinivas9922

they should clearly communicate what the model component represents. .pdf
they should clearly communicate what the model component represents. .pdfthey should clearly communicate what the model component represents. .pdf
they should clearly communicate what the model component represents. .pdf
srinivas9922
 
1. How did ODO operationalize the definition of an adult with a disa.pdf
1. How did ODO operationalize the definition of an adult with a disa.pdf1. How did ODO operationalize the definition of an adult with a disa.pdf
1. How did ODO operationalize the definition of an adult with a disa.pdf
srinivas9922
 
Which of the following statements about location is FALSE LatLong.pdf
Which of the following statements about location is FALSE LatLong.pdfWhich of the following statements about location is FALSE LatLong.pdf
Which of the following statements about location is FALSE LatLong.pdf
srinivas9922
 
#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf
srinivas9922
 

More from srinivas9922 (7)

they should clearly communicate what the model component represents. .pdf
they should clearly communicate what the model component represents. .pdfthey should clearly communicate what the model component represents. .pdf
they should clearly communicate what the model component represents. .pdf
 
1. How did ODO operationalize the definition of an adult with a disa.pdf
1. How did ODO operationalize the definition of an adult with a disa.pdf1. How did ODO operationalize the definition of an adult with a disa.pdf
1. How did ODO operationalize the definition of an adult with a disa.pdf
 
Write a program that do the following 1. Define one integer variable.pdf
Write a program that do the following 1. Define one integer variable.pdfWrite a program that do the following 1. Define one integer variable.pdf
Write a program that do the following 1. Define one integer variable.pdf
 
Which of the following statements about location is FALSE LatLong.pdf
Which of the following statements about location is FALSE LatLong.pdfWhich of the following statements about location is FALSE LatLong.pdf
Which of the following statements about location is FALSE LatLong.pdf
 
1) Supongamos que los gobiernos federal, estatal y local de Estados .pdf
1) Supongamos que los gobiernos federal, estatal y local de Estados .pdf1) Supongamos que los gobiernos federal, estatal y local de Estados .pdf
1) Supongamos que los gobiernos federal, estatal y local de Estados .pdf
 
1) Create logical design for the following ERD (20pts) MEMBER Member.pdf
1) Create logical design for the following ERD (20pts) MEMBER Member.pdf1) Create logical design for the following ERD (20pts) MEMBER Member.pdf
1) Create logical design for the following ERD (20pts) MEMBER Member.pdf
 
#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdf
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
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
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 

#include iostream#include iomanip#include fstreamusing n.pdf

  • 1. #include #include #include using namespace std; class DivSales { private: static double corpSales; double divSales; public: double qtrs[4]; DivSales() { divSales = 0.0; for (int i = 0; i < 4; i++) { qtrs[i] = 0.0; } } void setDivSales(double s) { divSales = s; corpSales += s; } double getDivSales() const { return divSales; } double getTotalSales() const { double total = 0.0; for (int i = 0; i < 4; i++) { total += qtrs[i]; } return total; } static double getCorpSales() { return corpSales; } friend istream& operator>>(istream& in, DivSales& ds) { double s;
  • 2. for (int i = 0; i < 4; i++) { in >> s; ds.qtrs[i] = s; ds.divSales += s; corpSales += s; } return in; } }; double DivSales::corpSales = 0.0; int main() { const int NUM_DIVISIONS = 6; DivSales divisions[NUM_DIVISIONS]; ifstream infile("SalesFile.txt"); for (int i = 0; i < NUM_DIVISIONS; i++) { infile >> divisions[i]; } int divisionNumber; bool quit = false; // Flag to control the loop while (!quit) { cout << "Enter division number (1-6), or 0 to quit: "; cin >> divisionNumber; if (divisionNumber == 0) { quit = true; // Set the flag to true to exit the loop } else if (divisionNumber < 1 || divisionNumber > NUM_DIVISIONS) { cout << "Invalid division number. Try again.n"; } else { const int divisionIndex = divisionNumber - 1; cout << "Sales for division " << divisionNumber << ":n"; for (int i = 0; i < 4; i++) { cout << "Division #" << divisionNumber << "tQuarter " << (i + 1) << ": $" << fixed << setprecision(2) << divisions[divisionIndex].qtrs[i] << "n"; } cout << "Division #" << divisionNumber << " total sales are: $" << fixed << setprecision(2) << divisions[divisionIndex].getTotalSales() << "n"; }
  • 3. } cout << "Total corporation sales: $" << fixed << setprecision(2) << DivSales::getCorpSales() << "n"; return 0; } How to prepare a test case/Multiple Test Cases document of the above program?