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

RENT.TXT B152043509450012425509186542 B192539511376024253311254535 B513439414745

ID: 3724888 • Letter: R

Question

RENT.TXT

B152043509450012425509186542
B192539511376024253311254535
B513439414745638721508563087
B411551508568014896209578400

Write a program to compute the profit or loss on apartment buildings.

Example input: RENT.TXT

B152042509350012425509186542

Columns:     1 –3        The apartment building identification number

                        4 – 5       The number of rental units in the building

                        6 – 8      The monthly rent per unit

                        9 – 14     The annual revenue received from the building

                        15 – 20   The annual cost of heating the building                      

                                        (9999v99 two places to the right of the decimal)

                        21 - 28   The interest payments made on a mortgage on the

                                        building (9999v99)

Output example:

                                                Revenue Statement 2017

                                                Dr. Pete’s Apartments Inc

Apt.     Units Rental     Annual       Annual      Annual        Occupancy    Gross

Bdg.                Rate        Revenue     Heating     Interest      Rate (%)         Profit(+)

                        Monthly                      Cost                                                        Lost(-)

B15      20       425         $93,500     $1,242.55 $91,865.42   91.67             $ 392.03+

Total Profit or Loss                                                                                        $???,???.??

In the output file, the occupancy rate is computed from the annual revenue as a percentage of the theoretically possible annual revenue from rents, that is, number of units times monthly rental times 12. The gross profit is the revenue less heating cost less interest payments. All dollar values must be formatted as above. Your output heading must include your name, assignment number and due date. Compute and print the total profit or loss for all the apartments.

When computing a value that may be negative you need a picture with the S

i.e.    05 profit-loss pic s99999v99.

And

i.e.    05 profit-loss-out pic +$999,999.99

Explanation / Answer

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

int main()

{

clrscr();

fstream f;

f.open("rent.txt",ios::in);

cout<<" Your Name";

// checking avaliablity of file

if(!f)

{

cout<<"no file";

return 0;

}

char c[50];

cout<< " Revenue Statemnet 2017" ;

cout<<" Dr Pete's Appartment Inc";

cout<< " Apt Bdg. Units Rental Rate Monthly Annual revenue Annual Heating Cost Annual Interest Occupancy Rate (%) Gross Profit(+) Lost(-) ";

int i;

char t[20];

int k,x, y, units;

double rental, revenue;

float heat, interest, occ, profit, total=0 ;

units=0;

while(!f.eof()) // till we reach enf of file

{

for(i=0;i<sizeof(t);i++)

t[i]=NULL;

f.getline(c,sizeof(c));

for(i=0;i<3;i++)

{

cout<<c[i];

}

t[0]=c[3];

t[1]=c[4];

units=atoi(t);

cout<<units;

for(i=0,k=5;k<8;k++,i++)

{

t[i]=c[k];

}

rental=atoi(t);

cout<<" "<<rental;

for(i=0,k=8;k<14;k++,i++)

{

t[i]=c[k];

}

revenue=atof(t);

cout<<" $"<< revenue;

for(i=0,k=14;k<20;k++,i++)

{

t[i]=c[k];

}

heat=atof(t)/100;

cout<<" $"<<heat;

for(i=0,k=21;k<28;k++,i++)

{

t[i]=c[k];

}

interest=atof(t)/100;

cout<<" $"<<interest;

occ=revenue/(units*rental*12)*100;

cout<<" "<<occ;

profit=revenue-heat-interest;

cout<<" $"<<profit<<endl;

total+=profit;

}

getch();

f.close();

return 0;

}