Finding the range of prices

I'm trying to figure out how to get the right price range when a user inputs their low and high price range. the highest price range for year 10 is 675K and the low is 240k. The other two are 490k and 520k.
Denver = 675k;
NYC = 520k;
SAC = 490k;
Phoenix = 240k;

if the user were to enter 275k for their low and 500k for their high how would I go about verifying every single price range to make sure its not in that price range?

This is what I have so far but it doesn't verify every single option.



if (yearChoice == 10 && lowestPrice <= 240000 && highestPrice >= 675000)
std::cout << "In 2028 NY, Phoenix, SAC, and Denver are in your price range";
else if (yearChoice == 10 && lowestPrice > 240000 && lowestPrice <= 490000 && highestPrice >= 675000)
std::cout << " NY, Phoenix, and Sacramento are in your price range.";
else if (yearChoice == 10 && lowestPrice > 490000 && lowestPrice <= 520000 && highestPrice >= 675000)
std::cout << "New York and Phoenix are in your price range";
else if (yearChoice == 10 && lowestPrice > 520000 && highestPrice >= 675000)
std::cout << "Phoenix is in your price range.";
//////////////////////////////////////////////////////////////////////////////////////////////////////
else if (yearChoice == 10 && lowestPrice <= 240000 && highestPrice < 675000 && highestPrice >= 520000)
std::cout << "New York, Sacramento and ,Denver are in your price range.";
else if (yearChoice == 10 && lowestPrice <= 240000 && highestPrice < 520000 && highestPrice >= 490000)
std::cout << "Sacramento and Denver are in your price range\n";
else if (yearChoice == 10 && lowestPrice <= 240000 && highestPrice < 490000 && highestPrice >=240000)
std::cout << "Denver is in your price range\n";
else if (yearChoice == 10 && lowestPrice >= 240000 && lowestPrice <= 490000 && highestPrice <= 675000 && highestPrice >= 520000)
std::cout << "Phoenix, NewYork, Sacramento, and Denver are all in your price range.\n";
Last edited on
1
2
3
for c in cities:
   if between(low, c.price, high):
      print(c.name, " is in range")
Topic archived. No new replies allowed.