Raphael is in a bit of a pinch this week. Since his school severely underpays him compared to the standard of living in Tokyo, he decided to start a part-time job at the famous book store chain Kinokuniya. However, since his employers think that he is good at C++, they asked him to gather some statistics from their database. They want to know how many employees work at Kinokuniya who are above 20 years and below 30 years of age (both inclusive).
Their database is stored in a file called database.txt. It consists of lines containing the employee ID (an integer), the employee's last and first names (two strings) (note that the last name comes first), the store ID (an integer which tells you which Kinokuniya the employee works at), the designation (a string), the age (an integer), and the shift (a string which is either "Morning" or "Afternoon" or "Both").
Your task is to help Raphael write a C++ program that reads the employee details from database.txt, stores them in a structure, and then simply cout's the number of employees in the age range 20-30, and also cout's the total number of employees.
Sample Input: (database.txt)
7372 Watabe Isamu 301 Worker 27 Afternoon
7374 Nakanoi Hokusai 301 Accountant 28 Afternoon
7375 Tsutomu Mayu 301 Accountant 25 Morning
7377 Takaoka Akuro 301 Manager 35 Both
7401 Hirano Ise 302 Accountant 31 Morning
Sample Output:
The number of employees in 20-30 age range: 3
The total number of employees: 5
C++ Program:
#include <iostream>
#include<bits/stdc++.h>
#define NoOfEmployees 5
using namespace std;
ifstream f("employee.txt");
struct employee{
int empID;
string lastName;
string firstName;
int storeId;
string designation;
int age;
string shift;
};
void showlist(list <struct employee> emp)
{
list <struct employee> :: iterator it;
for(it = emp.begin(); it != emp.end(); ++it)
cout <<it->empID<<'
'<<it->lastName<<'
'<<it->firstName<<' '<<it->storeId<<'
'<<it->designation<<it->age<<'
'<<it->shift<<endl;
cout<<endl;
}
int main()
{
struct employee emp;
int count=0;
list <struct employee> empl;
while(f>>emp.empID>>emp.lastName>>emp.firstName>>emp.storeId>>emp.designation>>emp.age>>emp.shift)
{
if(emp.age>=20 && emp.age <= 30)
count++;
empl.push_back(emp);
}
showlist(empl);
cout<<"The number of employees in 20-30 age range:
"<<count<<endl;
cout<<"Total No. of Employees:
"<<empl.size()<<endl<<endl;
return 0;
}
employee.txt:
7372 Watabe Isamu 301 Worker 27 Afternoon
7374 Nakanoi Hokusai 301 Accountant 28 Afternoon
7375 Tsutomu Mayu 301 Accountant 25 Morning
7377 Takaoka Akuro 301 Manager 35 Both
7401 Hirano Ise 302 Accountant 31 Morning
Output:

Raphael is in a bit of a pinch this week. Since his school severely underpays him...
In your judgement, and given only the facts described in this
case, should the management of Massey energy Company be held
morally responsible for the deaths of the 29 miners? Explain in
detail.
Suppose that nothing more is learned about the explosion other
than what is described in this case. Do you think Don Blankership
should be held morally responsible for the deaths of the 29 miners?
Explain in detail.
Given only the facts described in this case, should the...