SlideShare a Scribd company logo
1 of 9
Download to read offline
#include
#include
#include
#include
using namespace std;
// Define a Person class, including age, gender, and yearlyIncome.
class Person {
public:
Person();
void Print();
void SetData(int a); // FIXME Also set gender and yearly income
void SetGender(string gender);
void SetIncome(int income);
int GetAge();
string GetGender();
int GetIncome();
private:
int age;
string gender;
int yearlyIncome;
};
// Constructor for the Person class.
Person::Person() {
age = 0;
gender = "default";
yearlyIncome = 0;
return;
}
// Print the Person class.
void Person::Print() {
cout << "Age = " << this->age
<< ", gender = " << this->gender
<< ", yearly income = " << this->yearlyIncome
<< endl;
return;
}
// Set the age, gender, and yearlyIncome of a Person.
void Person::SetData(int a) { // FIXME Also set gender and yearly income
this->age = a;
return;
}
void Person::SetGender(string gender){
this->gender = gender;
}
void Person::SetIncome(int income){
this->yearlyIncome = income;
}
// Get the age of a Person.
int Person::GetAge() {
return this->age;
}
string Person::GetGender(){
return this->gender;
}
int Person::GetIncome() {
return this->yearlyIncome;
}
// Get a filename from program arguments, then make a Person for each line in the file.
bool ReadPeopleFromFile(int argc, char* argv[], vector &people) {
Person tmpPrsn;
ifstream inFS;
int tmpAge = 0;
string tmpGender = "";
int tmpYI = 0;
if (argc != 2) {
cout << " Usage: [EXECUTABLE FILE] [TEXT DATA FILE], e.g. myprog.exe
dev_people.txt" << endl;
return true; // indicates error
}
cout << "Opening file " << argv[1] << ". ";
inFS.open(argv[1]); // Try to open file
if (!inFS.is_open()) {
cout << "Could not open file " << argv[1] << ". ";
return true; // indicates error
}
while (!inFS.eof()) {
inFS >> tmpAge;
inFS >> tmpGender;
inFS >> tmpYI;
tmpPrsn.SetData(tmpAge); // FIXME Also set gender and yearly income
tmpPrsn.SetGender(tmpGender);
tmpPrsn.SetIncome(tmpYI);
tmpPrsn.Print();
people.push_back(tmpPrsn);
}
inFS.close();
cout << "Finished reading file." << endl;
return false; // indicates no error
}
// Ask user to enter age range.
void GetUserInput(int &ageLowerRange, int &ageUpperRange, string &gender, int
&yILowerIncome,int &yIHigherIncome) {
cout<<" Enter lower range of age: ";
cin >> ageLowerRange;
cout << "Enter upper range of age: ";
cin >> ageUpperRange;
cout << "Enter the gender: ";
cin >> gender;
cout << "Enter the lower range of yearlyIncome: ";
cin >> yILowerIncome;
cout << "Enter the higher range of yearlyIncome: ";
cin >> yIHigherIncome;
return;
}
// Return people within the given age range.
vector GetPeopleInAgeRange(vector ppl, int lowerRange, int upperRange) {
unsigned int i = 0;
vector pplInAgeRange;
int age = 0;
for (i = 0; i < ppl.size(); ++i) {
age = ppl.at(i).GetAge();
if ((age >= lowerRange) && (age <= upperRange)) {
pplInAgeRange.push_back(ppl.at(i));
}
}
return pplInAgeRange;
}
// Return people with same Gender.
vector GetPeopleWithSpecificGender(vector ptntlCstmrs,string gender){
vector pplWithSameGender;
string gndr;
for (int i=0;i GetPeopleInIncomeRange(vector ptntlCstmrs,int lowerRange, int higherRange){
vector pplInIncomeRange;
int range = 0;
for (int i=0;i= lowerRange) && (range <= higherRange)){
pplInIncomeRange.push_back(ptntlCstmrs.at(i));
}
}
return pplInIncomeRange;
}
int main(int argc, char* argv[]) {
vector ptntlCstmrs;
bool hadError = false;
int ageLowerRange = 0;
int ageUpperRange = 0;
string gender;
int yILowerIncome = 0;
int yIHigherIncome = 0;
hadError = ReadPeopleFromFile(argc, argv, ptntlCstmrs);
if( hadError ) {
return 1; // indicates error
}
GetUserInput(ageLowerRange, ageUpperRange, gender, yILowerIncome, yIHigherIncome );
ptntlCstmrs = GetPeopleInAgeRange(ptntlCstmrs, ageLowerRange, ageUpperRange);
ptntlCstmrs = GetPeopleWithSpecificGender(ptntlCstmrs,gender);
ptntlCstmrs = GetPeopleInIncomeRange(ptntlCstmrs,yILowerIncome,yIHigherIncome);
cout << " Number of potential customers = "<
Solution
HI Friend, I have separated code in seperate files.
Please let me know in case of any issue.
############# Person.h ##########
#include
using namespace std;
class Person {
public:
Person();
void Print();
void SetData(int a); // FIXME Also set gender and yearly income
void SetGender(string gender);
void SetIncome(int income);
int GetAge();
string GetGender();
int GetIncome();
private:
int age;
string gender;
int yearlyIncome;
};
############## Person.cpp #############
#include
#include "Person.h"
using namespace std;
// Constructor for the Person class.
Person::Person() {
age = 0;
gender = "default";
yearlyIncome = 0;
return;
}
// Print the Person class.
void Person::Print() {
cout << "Age = " << this->age
<< ", gender = " << this->gender
<< ", yearly income = " << this->yearlyIncome
<< endl;
return;
}
// Set the age, gender, and yearlyIncome of a Person.
void Person::SetData(int a) { // FIXME Also set gender and yearly income
this->age = a;
return;
}
void Person::SetGender(string gender){
this->gender = gender;
}
void Person::SetIncome(int income){
this->yearlyIncome = income;
}
// Get the age of a Person.
int Person::GetAge() {
return this->age;
}
string Person::GetGender(){
return this->gender;
}
int Person::GetIncome() {
return this->yearlyIncome;
}
############## PersonTest.cpp ###########
#include
#include
#include
#include
#include "Person.h"
using namespace std;
// Get a filename from program arguments, then make a Person for each line in the file.
bool ReadPeopleFromFile(int argc, char* argv[], vector &people) {
Person tmpPrsn;
ifstream inFS;
int tmpAge = 0;
string tmpGender = "";
int tmpYI = 0;
if (argc != 2) {
cout << " Usage: [EXECUTABLE FILE] [TEXT DATA FILE], e.g. myprog.exe
dev_people.txt" << endl;
return true; // indicates error
}
cout << "Opening file " << argv[1] << ". ";
inFS.open(argv[1]); // Try to open file
if (!inFS.is_open()) {
cout << "Could not open file " << argv[1] << ". ";
return true; // indicates error
}
while (!inFS.eof()) {
inFS >> tmpAge;
inFS >> tmpGender;
inFS >> tmpYI;
tmpPrsn.SetData(tmpAge); // FIXME Also set gender and yearly income
tmpPrsn.SetGender(tmpGender);
tmpPrsn.SetIncome(tmpYI);
tmpPrsn.Print();
people.push_back(tmpPrsn);
}
inFS.close();
cout << "Finished reading file." << endl;
return false; // indicates no error
}
// Ask user to enter age range.
void GetUserInput(int &ageLowerRange, int &ageUpperRange, string &gender, int
&yILowerIncome,int &yIHigherIncome) {
cout<<" Enter lower range of age: ";
cin >> ageLowerRange;
cout << "Enter upper range of age: ";
cin >> ageUpperRange;
cout << "Enter the gender: ";
cin >> gender;
cout << "Enter the lower range of yearlyIncome: ";
cin >> yILowerIncome;
cout << "Enter the higher range of yearlyIncome: ";
cin >> yIHigherIncome;
return;
}
// Return people within the given age range.
vector GetPeopleInAgeRange(vector ppl, int lowerRange, int upperRange) {
unsigned int i = 0;
vector pplInAgeRange;
int age = 0;
for (i = 0; i < ppl.size(); ++i) {
age = ppl.at(i).GetAge();
if ((age >= lowerRange) && (age <= upperRange)) {
pplInAgeRange.push_back(ppl.at(i));
}
}
return pplInAgeRange;
}
// Return people with same Gender.
vector GetPeopleWithSpecificGender(vector ptntlCstmrs,string gender){
vector pplWithSameGender;
string gndr;
for (int i=0;i GetPeopleInIncomeRange(vector ptntlCstmrs,int lowerRange, int higherRange){
vector pplInIncomeRange;
int range = 0;
for (int i=0;i= lowerRange) && (range <= higherRange)){
pplInIncomeRange.push_back(ptntlCstmrs.at(i));
}
}
return pplInIncomeRange;
}
int main(int argc, char* argv[]) {
vector ptntlCstmrs;
bool hadError = false;
int ageLowerRange = 0;
int ageUpperRange = 0;
string gender;
int yILowerIncome = 0;
int yIHigherIncome = 0;
hadError = ReadPeopleFromFile(argc, argv, ptntlCstmrs);
if( hadError ) {
return 1; // indicates error
}
GetUserInput(ageLowerRange, ageUpperRange, gender, yILowerIncome, yIHigherIncome );
ptntlCstmrs = GetPeopleInAgeRange(ptntlCstmrs, ageLowerRange, ageUpperRange);
ptntlCstmrs = GetPeopleWithSpecificGender(ptntlCstmrs,gender);
ptntlCstmrs = GetPeopleInIncomeRange(ptntlCstmrs,yILowerIncome,yIHigherIncome);
cout << " Number of potential customers = "<

More Related Content

Similar to #include iostream #include fstream #include vector #incl.pdf

Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfanandshingavi23
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdfanitasahani11
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsSwarup Boro
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfrajkumarm401
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdfannamalaiagencies
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxnormanibarber20063
 
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxproject4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxwkyra78
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfallystraders
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdfmhande899
 
This code has nine errors- but I don't know how to solve it- Please g.pdf
This code has nine errors- but I don't know how to solve it-  Please g.pdfThis code has nine errors- but I don't know how to solve it-  Please g.pdf
This code has nine errors- but I don't know how to solve it- Please g.pdfaamousnowov
 
C++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxC++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxRichardjOZTerryp
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdfannucommunication1
 
Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfankitmobileshop235
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfanwarsadath111
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfarihantgiftgallery
 

Similar to #include iostream #include fstream #include vector #incl.pdf (20)

Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdf
 
Program: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 studentsProgram: Inheritance in Class - to find topper out of 10 students
Program: Inheritance in Class - to find topper out of 10 students
 
Having issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdfHaving issues with passing my values through different functions aft.pdf
Having issues with passing my values through different functions aft.pdf
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
Tu1
Tu1Tu1
Tu1
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
PersonData.h#ifndef PersonData_h #define PersonData_h#inclu.pdf
 
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 
Najmul
Najmul  Najmul
Najmul
 
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxproject4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdf
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
 
This code has nine errors- but I don't know how to solve it- Please g.pdf
This code has nine errors- but I don't know how to solve it-  Please g.pdfThis code has nine errors- but I don't know how to solve it-  Please g.pdf
This code has nine errors- but I don't know how to solve it- Please g.pdf
 
C++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docxC++ 5-6-2 Basic derived class member override Define a member function.docx
C++ 5-6-2 Basic derived class member override Define a member function.docx
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
 
package employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdfpackage employeeType.employee;public class Employee {   private .pdf
package employeeType.employee;public class Employee {   private .pdf
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
 

More from shahidqamar17

At one time, the country of Aquilonia had no banks, but had curre.pdf
At one time, the country of Aquilonia had no banks, but had curre.pdfAt one time, the country of Aquilonia had no banks, but had curre.pdf
At one time, the country of Aquilonia had no banks, but had curre.pdfshahidqamar17
 
A certain element has a half life of 4.5 billion years. a. You find .pdf
A certain element has a half life of 4.5 billion years. a. You find .pdfA certain element has a half life of 4.5 billion years. a. You find .pdf
A certain element has a half life of 4.5 billion years. a. You find .pdfshahidqamar17
 
A linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfA linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfshahidqamar17
 
Workforce Management also called Human Resource Management manages o.pdf
Workforce Management also called Human Resource Management manages o.pdfWorkforce Management also called Human Resource Management manages o.pdf
Workforce Management also called Human Resource Management manages o.pdfshahidqamar17
 
Where has healthcare information management been historically How h.pdf
Where has healthcare information management been historically How h.pdfWhere has healthcare information management been historically How h.pdf
Where has healthcare information management been historically How h.pdfshahidqamar17
 
What were the successes and failures of the Progressive Movement, an.pdf
What were the successes and failures of the Progressive Movement, an.pdfWhat were the successes and failures of the Progressive Movement, an.pdf
What were the successes and failures of the Progressive Movement, an.pdfshahidqamar17
 
What is the difference between private sector, nonprofit sector, and.pdf
What is the difference between private sector, nonprofit sector, and.pdfWhat is the difference between private sector, nonprofit sector, and.pdf
What is the difference between private sector, nonprofit sector, and.pdfshahidqamar17
 
What are Cubas entrepreneurial opportunities and the status of .pdf
What are Cubas entrepreneurial opportunities and the status of .pdfWhat are Cubas entrepreneurial opportunities and the status of .pdf
What are Cubas entrepreneurial opportunities and the status of .pdfshahidqamar17
 
The LabVIEW G programming is considered to be a data flow programmin.pdf
The LabVIEW G programming is considered to be a data flow programmin.pdfThe LabVIEW G programming is considered to be a data flow programmin.pdf
The LabVIEW G programming is considered to be a data flow programmin.pdfshahidqamar17
 
what is a bottom heap up construction with an example pleaseSol.pdf
what is a bottom heap up construction with an example pleaseSol.pdfwhat is a bottom heap up construction with an example pleaseSol.pdf
what is a bottom heap up construction with an example pleaseSol.pdfshahidqamar17
 
What are the types of differences that exist between IFRS and U.S. G.pdf
What are the types of differences that exist between IFRS and U.S. G.pdfWhat are the types of differences that exist between IFRS and U.S. G.pdf
What are the types of differences that exist between IFRS and U.S. G.pdfshahidqamar17
 
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdf
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdfROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdf
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdfshahidqamar17
 
question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfshahidqamar17
 
Question 25 A Multilateral agreement in which countries signed to ban.pdf
Question 25 A Multilateral agreement in which countries signed to ban.pdfQuestion 25 A Multilateral agreement in which countries signed to ban.pdf
Question 25 A Multilateral agreement in which countries signed to ban.pdfshahidqamar17
 
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdf
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdfProve. Let n be a natural number. Any set of n integers {a1, a2, . ..pdf
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdfshahidqamar17
 
1Write a Java program that calculates and displays the Fibonacciseri.pdf
1Write a Java program that calculates and displays the Fibonacciseri.pdf1Write a Java program that calculates and displays the Fibonacciseri.pdf
1Write a Java program that calculates and displays the Fibonacciseri.pdfshahidqamar17
 
need an example of a System Anaysis and design project must have 3 .pdf
need an example of a System Anaysis and design project must have 3 .pdfneed an example of a System Anaysis and design project must have 3 .pdf
need an example of a System Anaysis and design project must have 3 .pdfshahidqamar17
 
Money laundering has become a mechanism for terrorist financing acti.pdf
Money laundering has become a mechanism for terrorist financing acti.pdfMoney laundering has become a mechanism for terrorist financing acti.pdf
Money laundering has become a mechanism for terrorist financing acti.pdfshahidqamar17
 
Let x be any set and let lambda SolutionProof. Obviously .pdf
Let x be any set and let lambda SolutionProof. Obviously .pdfLet x be any set and let lambda SolutionProof. Obviously .pdf
Let x be any set and let lambda SolutionProof. Obviously .pdfshahidqamar17
 
Java public cts Node t next ni next SolutionYou hav.pdf
Java public cts Node t next ni next SolutionYou hav.pdfJava public cts Node t next ni next SolutionYou hav.pdf
Java public cts Node t next ni next SolutionYou hav.pdfshahidqamar17
 

More from shahidqamar17 (20)

At one time, the country of Aquilonia had no banks, but had curre.pdf
At one time, the country of Aquilonia had no banks, but had curre.pdfAt one time, the country of Aquilonia had no banks, but had curre.pdf
At one time, the country of Aquilonia had no banks, but had curre.pdf
 
A certain element has a half life of 4.5 billion years. a. You find .pdf
A certain element has a half life of 4.5 billion years. a. You find .pdfA certain element has a half life of 4.5 billion years. a. You find .pdf
A certain element has a half life of 4.5 billion years. a. You find .pdf
 
A linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdfA linear system is always time-invariant.SolutionNo its false. .pdf
A linear system is always time-invariant.SolutionNo its false. .pdf
 
Workforce Management also called Human Resource Management manages o.pdf
Workforce Management also called Human Resource Management manages o.pdfWorkforce Management also called Human Resource Management manages o.pdf
Workforce Management also called Human Resource Management manages o.pdf
 
Where has healthcare information management been historically How h.pdf
Where has healthcare information management been historically How h.pdfWhere has healthcare information management been historically How h.pdf
Where has healthcare information management been historically How h.pdf
 
What were the successes and failures of the Progressive Movement, an.pdf
What were the successes and failures of the Progressive Movement, an.pdfWhat were the successes and failures of the Progressive Movement, an.pdf
What were the successes and failures of the Progressive Movement, an.pdf
 
What is the difference between private sector, nonprofit sector, and.pdf
What is the difference between private sector, nonprofit sector, and.pdfWhat is the difference between private sector, nonprofit sector, and.pdf
What is the difference between private sector, nonprofit sector, and.pdf
 
What are Cubas entrepreneurial opportunities and the status of .pdf
What are Cubas entrepreneurial opportunities and the status of .pdfWhat are Cubas entrepreneurial opportunities and the status of .pdf
What are Cubas entrepreneurial opportunities and the status of .pdf
 
The LabVIEW G programming is considered to be a data flow programmin.pdf
The LabVIEW G programming is considered to be a data flow programmin.pdfThe LabVIEW G programming is considered to be a data flow programmin.pdf
The LabVIEW G programming is considered to be a data flow programmin.pdf
 
what is a bottom heap up construction with an example pleaseSol.pdf
what is a bottom heap up construction with an example pleaseSol.pdfwhat is a bottom heap up construction with an example pleaseSol.pdf
what is a bottom heap up construction with an example pleaseSol.pdf
 
What are the types of differences that exist between IFRS and U.S. G.pdf
What are the types of differences that exist between IFRS and U.S. G.pdfWhat are the types of differences that exist between IFRS and U.S. G.pdf
What are the types of differences that exist between IFRS and U.S. G.pdf
 
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdf
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdfROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdf
ROT13 (rotate by 13 places) is a simple letter substitution cipher t.pdf
 
question.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdfquestion.(player, entity ,field and base.java codes are given)Stop.pdf
question.(player, entity ,field and base.java codes are given)Stop.pdf
 
Question 25 A Multilateral agreement in which countries signed to ban.pdf
Question 25 A Multilateral agreement in which countries signed to ban.pdfQuestion 25 A Multilateral agreement in which countries signed to ban.pdf
Question 25 A Multilateral agreement in which countries signed to ban.pdf
 
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdf
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdfProve. Let n be a natural number. Any set of n integers {a1, a2, . ..pdf
Prove. Let n be a natural number. Any set of n integers {a1, a2, . ..pdf
 
1Write a Java program that calculates and displays the Fibonacciseri.pdf
1Write a Java program that calculates and displays the Fibonacciseri.pdf1Write a Java program that calculates and displays the Fibonacciseri.pdf
1Write a Java program that calculates and displays the Fibonacciseri.pdf
 
need an example of a System Anaysis and design project must have 3 .pdf
need an example of a System Anaysis and design project must have 3 .pdfneed an example of a System Anaysis and design project must have 3 .pdf
need an example of a System Anaysis and design project must have 3 .pdf
 
Money laundering has become a mechanism for terrorist financing acti.pdf
Money laundering has become a mechanism for terrorist financing acti.pdfMoney laundering has become a mechanism for terrorist financing acti.pdf
Money laundering has become a mechanism for terrorist financing acti.pdf
 
Let x be any set and let lambda SolutionProof. Obviously .pdf
Let x be any set and let lambda SolutionProof. Obviously .pdfLet x be any set and let lambda SolutionProof. Obviously .pdf
Let x be any set and let lambda SolutionProof. Obviously .pdf
 
Java public cts Node t next ni next SolutionYou hav.pdf
Java public cts Node t next ni next SolutionYou hav.pdfJava public cts Node t next ni next SolutionYou hav.pdf
Java public cts Node t next ni next SolutionYou hav.pdf
 

Recently uploaded

An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
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
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsISCOPE Publication
 
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
 
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 Partnershipsexpandedwebsite
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscapingDr. M. Kumaresan Hort.
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
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
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 

Recently uploaded (20)

An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
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
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
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
 
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
 
Climbers and Creepers used in landscaping
Climbers and Creepers used in landscapingClimbers and Creepers used in landscaping
Climbers and Creepers used in landscaping
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
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
 
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"
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
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
 

#include iostream #include fstream #include vector #incl.pdf

  • 1. #include #include #include #include using namespace std; // Define a Person class, including age, gender, and yearlyIncome. class Person { public: Person(); void Print(); void SetData(int a); // FIXME Also set gender and yearly income void SetGender(string gender); void SetIncome(int income); int GetAge(); string GetGender(); int GetIncome(); private: int age; string gender; int yearlyIncome; }; // Constructor for the Person class. Person::Person() { age = 0; gender = "default"; yearlyIncome = 0; return; } // Print the Person class. void Person::Print() { cout << "Age = " << this->age << ", gender = " << this->gender << ", yearly income = " << this->yearlyIncome << endl; return;
  • 2. } // Set the age, gender, and yearlyIncome of a Person. void Person::SetData(int a) { // FIXME Also set gender and yearly income this->age = a; return; } void Person::SetGender(string gender){ this->gender = gender; } void Person::SetIncome(int income){ this->yearlyIncome = income; } // Get the age of a Person. int Person::GetAge() { return this->age; } string Person::GetGender(){ return this->gender; } int Person::GetIncome() { return this->yearlyIncome; } // Get a filename from program arguments, then make a Person for each line in the file. bool ReadPeopleFromFile(int argc, char* argv[], vector &people) { Person tmpPrsn; ifstream inFS; int tmpAge = 0; string tmpGender = ""; int tmpYI = 0; if (argc != 2) { cout << " Usage: [EXECUTABLE FILE] [TEXT DATA FILE], e.g. myprog.exe dev_people.txt" << endl; return true; // indicates error } cout << "Opening file " << argv[1] << ". "; inFS.open(argv[1]); // Try to open file
  • 3. if (!inFS.is_open()) { cout << "Could not open file " << argv[1] << ". "; return true; // indicates error } while (!inFS.eof()) { inFS >> tmpAge; inFS >> tmpGender; inFS >> tmpYI; tmpPrsn.SetData(tmpAge); // FIXME Also set gender and yearly income tmpPrsn.SetGender(tmpGender); tmpPrsn.SetIncome(tmpYI); tmpPrsn.Print(); people.push_back(tmpPrsn); } inFS.close(); cout << "Finished reading file." << endl; return false; // indicates no error } // Ask user to enter age range. void GetUserInput(int &ageLowerRange, int &ageUpperRange, string &gender, int &yILowerIncome,int &yIHigherIncome) { cout<<" Enter lower range of age: "; cin >> ageLowerRange; cout << "Enter upper range of age: "; cin >> ageUpperRange; cout << "Enter the gender: "; cin >> gender; cout << "Enter the lower range of yearlyIncome: "; cin >> yILowerIncome; cout << "Enter the higher range of yearlyIncome: "; cin >> yIHigherIncome; return; } // Return people within the given age range. vector GetPeopleInAgeRange(vector ppl, int lowerRange, int upperRange) { unsigned int i = 0;
  • 4. vector pplInAgeRange; int age = 0; for (i = 0; i < ppl.size(); ++i) { age = ppl.at(i).GetAge(); if ((age >= lowerRange) && (age <= upperRange)) { pplInAgeRange.push_back(ppl.at(i)); } } return pplInAgeRange; } // Return people with same Gender. vector GetPeopleWithSpecificGender(vector ptntlCstmrs,string gender){ vector pplWithSameGender; string gndr; for (int i=0;i GetPeopleInIncomeRange(vector ptntlCstmrs,int lowerRange, int higherRange){ vector pplInIncomeRange; int range = 0; for (int i=0;i= lowerRange) && (range <= higherRange)){ pplInIncomeRange.push_back(ptntlCstmrs.at(i)); } } return pplInIncomeRange; } int main(int argc, char* argv[]) { vector ptntlCstmrs; bool hadError = false; int ageLowerRange = 0; int ageUpperRange = 0; string gender; int yILowerIncome = 0; int yIHigherIncome = 0; hadError = ReadPeopleFromFile(argc, argv, ptntlCstmrs); if( hadError ) { return 1; // indicates error } GetUserInput(ageLowerRange, ageUpperRange, gender, yILowerIncome, yIHigherIncome );
  • 5. ptntlCstmrs = GetPeopleInAgeRange(ptntlCstmrs, ageLowerRange, ageUpperRange); ptntlCstmrs = GetPeopleWithSpecificGender(ptntlCstmrs,gender); ptntlCstmrs = GetPeopleInIncomeRange(ptntlCstmrs,yILowerIncome,yIHigherIncome); cout << " Number of potential customers = "< Solution HI Friend, I have separated code in seperate files. Please let me know in case of any issue. ############# Person.h ########## #include using namespace std; class Person { public: Person(); void Print(); void SetData(int a); // FIXME Also set gender and yearly income void SetGender(string gender); void SetIncome(int income); int GetAge(); string GetGender(); int GetIncome(); private: int age; string gender; int yearlyIncome; }; ############## Person.cpp ############# #include #include "Person.h" using namespace std; // Constructor for the Person class. Person::Person() { age = 0; gender = "default"; yearlyIncome = 0;
  • 6. return; } // Print the Person class. void Person::Print() { cout << "Age = " << this->age << ", gender = " << this->gender << ", yearly income = " << this->yearlyIncome << endl; return; } // Set the age, gender, and yearlyIncome of a Person. void Person::SetData(int a) { // FIXME Also set gender and yearly income this->age = a; return; } void Person::SetGender(string gender){ this->gender = gender; } void Person::SetIncome(int income){ this->yearlyIncome = income; } // Get the age of a Person. int Person::GetAge() { return this->age; } string Person::GetGender(){ return this->gender; } int Person::GetIncome() { return this->yearlyIncome; } ############## PersonTest.cpp ########### #include #include #include #include
  • 7. #include "Person.h" using namespace std; // Get a filename from program arguments, then make a Person for each line in the file. bool ReadPeopleFromFile(int argc, char* argv[], vector &people) { Person tmpPrsn; ifstream inFS; int tmpAge = 0; string tmpGender = ""; int tmpYI = 0; if (argc != 2) { cout << " Usage: [EXECUTABLE FILE] [TEXT DATA FILE], e.g. myprog.exe dev_people.txt" << endl; return true; // indicates error } cout << "Opening file " << argv[1] << ". "; inFS.open(argv[1]); // Try to open file if (!inFS.is_open()) { cout << "Could not open file " << argv[1] << ". "; return true; // indicates error } while (!inFS.eof()) { inFS >> tmpAge; inFS >> tmpGender; inFS >> tmpYI; tmpPrsn.SetData(tmpAge); // FIXME Also set gender and yearly income tmpPrsn.SetGender(tmpGender); tmpPrsn.SetIncome(tmpYI); tmpPrsn.Print(); people.push_back(tmpPrsn); } inFS.close(); cout << "Finished reading file." << endl; return false; // indicates no error } // Ask user to enter age range. void GetUserInput(int &ageLowerRange, int &ageUpperRange, string &gender, int
  • 8. &yILowerIncome,int &yIHigherIncome) { cout<<" Enter lower range of age: "; cin >> ageLowerRange; cout << "Enter upper range of age: "; cin >> ageUpperRange; cout << "Enter the gender: "; cin >> gender; cout << "Enter the lower range of yearlyIncome: "; cin >> yILowerIncome; cout << "Enter the higher range of yearlyIncome: "; cin >> yIHigherIncome; return; } // Return people within the given age range. vector GetPeopleInAgeRange(vector ppl, int lowerRange, int upperRange) { unsigned int i = 0; vector pplInAgeRange; int age = 0; for (i = 0; i < ppl.size(); ++i) { age = ppl.at(i).GetAge(); if ((age >= lowerRange) && (age <= upperRange)) { pplInAgeRange.push_back(ppl.at(i)); } } return pplInAgeRange; } // Return people with same Gender. vector GetPeopleWithSpecificGender(vector ptntlCstmrs,string gender){ vector pplWithSameGender; string gndr; for (int i=0;i GetPeopleInIncomeRange(vector ptntlCstmrs,int lowerRange, int higherRange){ vector pplInIncomeRange; int range = 0; for (int i=0;i= lowerRange) && (range <= higherRange)){ pplInIncomeRange.push_back(ptntlCstmrs.at(i)); }
  • 9. } return pplInIncomeRange; } int main(int argc, char* argv[]) { vector ptntlCstmrs; bool hadError = false; int ageLowerRange = 0; int ageUpperRange = 0; string gender; int yILowerIncome = 0; int yIHigherIncome = 0; hadError = ReadPeopleFromFile(argc, argv, ptntlCstmrs); if( hadError ) { return 1; // indicates error } GetUserInput(ageLowerRange, ageUpperRange, gender, yILowerIncome, yIHigherIncome ); ptntlCstmrs = GetPeopleInAgeRange(ptntlCstmrs, ageLowerRange, ageUpperRange); ptntlCstmrs = GetPeopleWithSpecificGender(ptntlCstmrs,gender); ptntlCstmrs = GetPeopleInIncomeRange(ptntlCstmrs,yILowerIncome,yIHigherIncome); cout << " Number of potential customers = "<