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

(Must be C++ language) A real estate office handles, say, 50 apartment units. Wh

ID: 668292 • Letter: #

Question

(Must be C++ language) 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?

Write a program that prompts the user to enter:

a. The rent to occupy all the units.

b. The increase in rent that results in a vacant unit.

c. Amount to maintain a rented unit.

The program then outputs the number of units to be rented to maximize the profit.

Explanation / Answer

#include <iostream>
using namespace std;
#include<fstream>
int main ()
06
{
double rent, maintenance, maintenanceCost,increaseRent;
double income,profit, maxProfit=0;
int n;
ofstream outFile;
cout << "The rent to occupy all units: ";
cin >> rent;
cout << "The increase in rent that results from a vacant unit";
cin >> increaseRent;
cout << "The amount to maintain a rented unit: ";
cin >> 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 << rent << " " << units << " " << maintenance << " " << income<< " " << profit << " ";
}
outFile.close();
cout << "number units to be rented to maximize profit is ";
cout << n;
cout << " ";
return 0;
}