Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Above are the output and please help me to complete the C++ code in //Your code. Thank you and there is a file named person.txt

image text in transcribed

Above are the output and please help me to complete the C++ code in "//Your code". Thank you and there is a file named "person.txt" and I can't give the file here because it is in .txt and it consist of 93 pages so you please help me with the codes and I can improvise just tell me where to put the"person.txt". The file is the birth year-month-date then gender then income. The n(total people) is 5000.For example:

1920-01-09 M 0 1920-01-27 M 0 1920-03-16 F 0 1920-04-03 M 0 1920-04-14 M 0 1920-04-14 F 0

#include

#include

#include

#include

#include

using namespace std;

struct person

{

string dob; // date of birth, yyyy-mm-dd

char gender; // 'F' for female, 'M' for male

double income;

};

ostream& operator

{

os

return os;

}

// Use of global variable is acceptable if it is read only.

const string today = "2020-02-24";

// --------------------------------------- functions to be implemented by student

// You may define other supporting functions, if required.

void analyse(const person *list, int n, int age_L, int age_H)

{

// preconditions: list[] is sorted by dob in ascending order,

// n = length of list, and age_H >= age_L

// age_L and age_H (inclusive) define an age-group.

// Age is determined as of today (a constant value is used in this exercise).

// Find the average income of females, and average income of males in the

age-group.

// Print the results to standard output.

// Do not traverse the array from the beginning using sequential search.

// Use binary search to locate a person within the age-group,

// and then process persons in the age-group sequentially.

// For age_L = 50, age_H = 59, and today = "2020-02-24", process persons

// that were born after 1960-02-24, and were born on or before 1970-02-24.

// Do not hardcode the dates in your program.

// Values of age_L, age_H and today may vary.

// Your codes.

/*

cout

cout

age_H

// Other print statements required. See the jpeg file for the requirements.

*/

}

// -------------------------------------------------- functions given to student

person* readDataFile(string filename, int& n)

{

ifstream infile;

infile.open(filename);

if (infile.is_open() == false)

{

cout

system("pause");

exit(0);

}

string temp;

infile >> temp >> n;

person *list = new person[n];

for (int i = 0; i

infile >> list[i].dob >> list[i].gender >> list[i].income;

return list;

}

int main()

{

// Put the data file "persons.txt" in the working directory of your project.

// Suppose your project is located at c:\myProject,

// put the data file in c:\myProject\myProject

int n = 0;

person *list = readDataFile("persons.txt", n); // DO not modify this

statement

analyse(list, n, 50, 59);

system("pause");

return 0;

}

"person.txt" :

n 5000 1920-01-09 M 0 1920-01-27 M 0 1920-03-16 F 0 1920-04-03 M 0 1920-04-14 M 0 1920-04-14 F 0 1920-04-22 M 0 1920-05-10 F 0 1920-05-15 F 0 1920-05-16 M 0 1920-05-16 M 0 1920-05-21 F 0 1920-05-26 F 0 1920-05-27 M 0 1920-05-29 F 0 1920-06-30 M 0 1920-07-01 M 0 1920-07-12 M 0 1920-07-13 F 0 1920-08-06 M 0 1920-08-11 M 0 1920-08-14 M 0 1920-08-22 F 0 1920-08-30 M 0 1920-08-30 M 0 1920-09-06 F 0 1920-09-11 M 0 1920-09-19 M 0 1920-09-20 F 0

and still many more

- O X D:\Work\TEACH\EE2331 - C-Plus-Plus 2020-01\Project-2020-01\Debug\Project-2020-01.exe Reference date is 2020-02-24 Index range of persons in the age-group 50 to 59: Start index = 1988 to end index (inclusive) = 2470 list[start] : 1960-03-05 F 164521 list[end] : 1970-02-07 F 90325 Number of females in age-group 50 to 59 = 235 Average income of females in the age-group = 79994.9 Number of males in age-group 50 to 59 = 248 Average income of males in the age-group = 87532.4, Press any key to continue ... - O X D:\Work\TEACH\EE2331 - C-Plus-Plus 2020-01\Project-2020-01\Debug\Project-2020-01.exe Reference date is 2020-02-24 Index range of persons in the age-group 50 to 59: Start index = 1988 to end index (inclusive) = 2470 list[start] : 1960-03-05 F 164521 list[end] : 1970-02-07 F 90325 Number of females in age-group 50 to 59 = 235 Average income of females in the age-group = 79994.9 Number of males in age-group 50 to 59 = 248 Average income of males in the age-group = 87532.4, Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago