1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <map>
#include <string>
void waitForEnter();
int main()
{
std::map<double, std::string> family { { 50'000.00, "programmer" },
{ 100'000.00, "poor" },
{ 300'000.00, "lower-middle" },
{ 400'000.00, "middle" },
{ 500'000.00, "wealthy" },
{ 600'000.00, "politician" },
{ 1'000'000.00, "plumber" } };
std::cout << "Input family income: ";
double income;
std::cin >> income;
std::cout << "Your income bracket is "
<< (family.upper_bound(income) == family.end() ?
family.rbegin()->second : family.upper_bound(income)->second)
<< '\n';
waitForEnter();
return 0;
}
void waitForEnter()
{
std::cout << "\nPress ENTER to continue...\n";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
|