Reference no: EM133201523
A function named surgerySelector that receives a vector of Hospital as the parameter (std::vector) and returns Hospital. This functions performs the following tasks:
- Print how many hospitals can perform surgeries for back and heart.
- Print to the screen the name(s) of hospital(s) and surgeries whose price is below 80000.
- Calculate and print to the screen the average price for 'back' surgeries.
- Print if any hospital(s) which is/are not equipped for any surgery. Print 'Yes' if there are any or 'No' in the other case. Also print the number of hospitals you found in either case.
- Sort the vector of Hospitals with prices low to high
*** Do not use Manual loops!
*** Do not use the same algorithm more than once!
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
using namespace std;
enum class surgery_type
{
back, brain, heart
};
struct Hospital
{
std::string name;
surgery_type type;
bool equipped;
double price;
};
Hospital surgerySelector(vector<Hospital> perform) {
//your code here
return hh;
}
int main() {
std::vector<Hospital> performSurgery({
{ "Stouville", surgery_type::back, true, 30000.00},
{ "Scarbrough", surgery_type::back, false, 25000.00},
{ "Scarbrough", surgery_type::brain, false, 100000.00 },
{ "Toronto", surgery_type::brain, true, 105000.00},
{ "Toronto", surgery_type::back, true, 40000.00 },
{ "Toronto", surgery_type::heart, true, 49000.00 },
{ "Stouville", surgery_type::heart, true, 45000.00 },
});
auto res = surgerySelector(performSurgery);
return 0;
}