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 the program to prompt the user to enter:
Enter the number of apartments
Enter the rent for each apartment
Enter maintenance expense for each rented apartment
Enter the amount of rent increase per apartment
I'm not getting any errors, but the program is not displaying any ouput, what did i do wrong?
import java.io.*;
import java.util.*;
public class lab9_2 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter number of apartments");
double no_of_apartments;
no_of_apartments=in.nextDouble();
System.out.println("Enter rent of each apartment");
double rent_per_apartment;
rent_per_apartment=in.nextDouble();
System.out.println("Enter maintanence expense for each rented apartment");
double mApts;
mApts=in.nextDouble();
System.out.println("Enter the amount of rent increase per apartment");
double rInc;
rInc=in.nextDouble();
double rApts;
rApts=in.nextDouble();
double maxprofit=0.0;
double maxNOofunits=0;
double noOfrentUnits = 0;
while(noOfrentUnits==0){
double vacantunits;
vacantunits=mApts-noOfrentUnits;
double totalrentincrease;
totalrentincrease=vacantunits*rInc;
double adjustedrentperapt;
adjustedrentperapt=rApts+totalrentincrease;
double totalrent;
totalrent=adjustedrentperapt*noOfrentUnits;
double maintanenceExpense;
maintanenceExpense=noOfrentUnits*mApts;
double profit;
profit=totalrent-maintanenceExpense;
if(maxprofit<profit){
maxprofit=profit;
maxNOofunits=noOfrentUnits;
System.out.println("Maximum number of units to rent:"+maxNOofunits);
System.out.println("Maximum profit:"+maxprofit);
maxNOofunits++;
maxprofit++;
}//end while loop
}
}//end main
}//end class