Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please look at all the info before you reply, must be C++ 19.5 C++: Apartment Pr

ID: 3675165 • Letter: P

Question

Please look at all the info before you reply, must be C++

19.5 C++: Apartment Problem

A real estate office handles, say, 50 apartment units. When the rent is, say, $600 per month, all the units are occupied. However, for each, say, $40 increase in rent, one unit becomes vacant. Moreover, each occupied unit requires an average of $27 per month for maintenance. How many units should be rented to maximize the profit?

#include <iostream>
using namespace std;

int main() {

   /* Type your code here. */

   return 0;
}

Explanation / Answer

#include using namespace std; #include int main () { double rent, maintenance, maintenanceCost,increaseRent; double income,profit, maxProfit=0; int n; ofstream outFile; cout > rent; cout > increaseRent; cout > maintenanceCost; outFile.open("apartments.txt"); for(int units = 50; units > 0; units--, rent += increaseRent) { income = units * rent; maintenance = units * maintenanceCost; profit = income - maintenance; if (profit > maxProfit) { maxProfit = profit; n = units; } outFile