# Computer Programming

posted by .

I'm trying to create a vba code that solves this problem: 50 apartment units rent for 600 a month, for each 40 dollar increase in rent a unit becomes unoccupied. I want to find the max profit and number of units at that number.

Sub Rent()
Dim Rent As Variant
Dim increase As Integer
Dim units As Object
Dim Profit As Double
Rent = InputBox("The rent to occupy all the units")
increase = InputBox("The increase in rent that results in a vacant unit")
Rent = Rent + increasea
units = 50
Profit = units * (600 + increase)

Outputbox " " & units & " units and " & Profit & " when profit is maximized."
End Sub

• Computer Programming -

Your code seems to be in reasonable shape, except that it does not yet implement the algorithm to find the maximum revenue.

So the current revenue is 600*50=30,000\$ a month.
Your program will increase the rent by \$40 steps and recalculate the revenue.
When the revenue starts to decrease, then you have found the maximum revenue.

The programming part will include a for loop for implementing the increase, a method to calculate the new revenue, a variable to keep the old revenue, and an if statement to jump out of the loop when the revenue decreases.

The pseudocode would look something like this:

Define all variables
1. Input current rent (Rent=600\$), number of units (Units=50), and critical increase (Increase=40\$)
Current revenue (Revenue)=Units*Rent

2. Loop over increases
For inc=40 to Units*40 step40
NewRent=Rent+inc
NewUnits=Units-(inc/40)
NewRevenue=NewRent*NewUnits
If NewRevenue<revenue then exit loop
Revenue=NewRevenue
next inc
Rem: Found max. increase
Output revenue
Output NewUnits-1

If you implement the above pseudocode, you should get the correct result of \$1300 as the most profitable rent with a revenue of \$42250.

## Similar Questions

1. ### Calculus

The manager of a large apartment complex knows from experience that 90 units will be occupied if the rent is 370 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 5 dollar …
2. ### Calculus

The manager of a large apartment complex knows from experience that 80 units will be occupied if the rent is 472 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 4 dollar …
3. ### Calculus

The manager of a large apartment complex knows from experience that 80 units will be occupied if the rent is 460 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 10 dollar …
4. ### Math 1200

a complex has 205 apartment units. When the rent is \$635 per month all 205 units are occupied.Assume that for each \$75 increase in rent 15 units becomes vacent. Assume that the number of occupied units is a linear function of the rent. …
5. ### Calculus

The manager of a large apartment complex knows from experience that 90 units will be occupied if the rent is 360 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 9 dollar …
6. ### Calculus-Applied Optimization Problem

The manager of a large apartment complex knows from experience that 100 units will be occupied if the rent is 425 dollars per month. A market survey suggests that, on average, one additional unit will remain vacant for each 9 dollar …
7. ### Calculus: Help Me

The manager of a large apartment complex knows from experience that 120 units will be occupied if the rent is 294 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 7 dollar …
8. ### Calculus

The manager of a large apartment complex knows from experience that 80 units will be occupied if the rent is 460 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 10 dollar …
9. ### Math 115

The manager of a large apartment complex knows from experience that 90 units will be occupied if the rent is 444 dollars per month. A market survey suggests that, on the average, one additional unit will remain vacant for each 6 dollar …
10. ### Calculus/Optimisation

A real estate manages 80 apartment units. When the rent of each unit is \$180 per month, all units are occupied. However, for each \$6 increase in rent, one of the units becomes vacant. Each occupied unit requires an average of \$18 per …

More Similar Questions