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

Please Help! C++ Code I need to make it as simple as possible Im having issues.

ID: 3812775 • Letter: P

Question

Please Help! C++ Code

I need to make it as simple as possible

Im having issues.

--------------------------------------------------------------------------------------------------

REALTOR ASSIST v1.0 (with File I/O)

A realtor friend of mine could use a program that would allow her to keep track of real estate property listings.

Here are the main features of the program

1) New Property [30 points]

The realtor uses this feature to add a new property listing to the program. For each property, the program should ask for the property number (a number between 120000),the asking price of the property (currency) and the number of bedrooms (a number). Your program should not accept a property whose price is less than $50,000 and greater than 10,000,000. Also each property must have at least 1 bedroom (no max limit). If the property does not conform to

these rules, you may display an error message and cancel out of the feature (to the main screen).

2) Price Reduction [40 points]

We often go into price reduction if the property is not sold for a certain period of time (a year or so). So, we need a feature where the realtor can enter a reduction price. The program should ask for the property ID and the amount of reduction. Find the home with the provided property ID and reduce its price by reduction amount so you need to subtract the reduction from current price of the property.

3) Search Property [50 points]

During meetings with potential buyers, the realtor often feels the need to search the inventory based on the budget and the need of the buyer. We need this feature so that realtor can input the maximum price the buyer is willing to pay and the minimum number of bedrooms desired. The program should scan the inventory for all properties with price tag less than or equal to the amount buyer wants to pay and the number of bedrooms greater than or equal to the number of bedrooms needed by the buyer. The results should be displayed on screen (one property per line).

4) Report [30 points]

Displays all the properties in the program along with their price tags and number of bedrooms. This report, at the end, should also display average home price.

5) Exit [5 points]

Exits the program.

Make sure that your program is presentable, user friendly (15 points).

Make sure that the information is saved to/from a data file. (30 points)

Avoid Penalties:

Each feature must be in a separate function (50).

You must use arrays to hold the data (50)

I will deduct up to 30 points for indentation problem and/or not properly commenting your code,

I will deduct up to 40 points if your program have some usability problems. Ex. you must cout what user is supposed to enter before collecting an input with cin. Properly and neatly format the main menu of the program.

I will deduct up to 50 points if your program does not compile. Make sure that you aremsubmitting a program that compiles.

I will deduct up to 30 points if your program has runtime error (crashing while running).

You should expect that I will deduct the maximum points specified if you stumble upon these

penalties.

If you implement the code properly, your program will obviously output correct information.

However, your program outputting correct information does not mean that you implemented the

program correctly. I am not grading the output only your code. If a function is not implemented properly, I may still grant nominal points at my discretion.

--------------------------

PLEASE IT NEEDS TO BE EXTREMLEY SIMPLE

Cin / Cout for menu

If statements

For loops

While loops

Arrays ( parallel arrays)

6.File open/close

Reading data/ and writing data into a .txt file

------------HERE ARE HINTS----------------------------

THIS IS JUST A HINT OF WHAT IT COULD LOOK LIKE, THIS IS NOT THE ACTUAL CODE

ALL YOU NEED for boiler plate is something like this

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

// example file open and close

void …(string …[], int …[], double … [], int &…t)

{

            ifstream file;

            file.open("data.txt");

    if(file){

                        file >> …;

                        for(int i=0; i < … i++)

                                    file >> … [i] >> s… [i] >> price[i];

    }

            file.close();

}

void … (string … [], int … [], double … [], int &…)

{

            ofstream file;

            file.open("Propertydata.txt");

            file << count << endl;

            for(int i=0; i < Count; i++)

                        file << …[i] << " " << … [i] << " " << price[i] << endl;

            file.close();

}

//menu inserts

void (string, int, double)….

void (string, int, double)….

void (string, int, double)….

void (string, int, double)….

Int main()

String[]

Int []

Double[]

Int

///And so forth…….

Do

{

// example Menu insert

            cout << "1 – Add New Property" << endl;

            cout << "2 – Reduce price of Property" << endl;

            cout << "3 – Search Property" << endl;

            cout << "4 - Display all Properties" << endl;

            cout << "5 - Exit" << endl;

            cout << "What do you want? ";

            int choice;

                        cin >> choice;

                        if (choice == 1)

AddNewProperty (…,   …,   … , Count);

                        else if (choice == 2)

Reduce price of Property (…,   …,   … , Count);

                        else if (choice == 3)

SearchProperty (…,   …,   … , Count);

                        else if (choice == 4)

                        {

                                    double … = DisplayAllProperty (…,   …,   … , Count);

                                    cout << "These are all the properties " <<   … << price << bedroomnumber;

                                    cout <<” The average home price is “ << avghomeprice <<;

                        }

}

While (choice !=5)

// save changes to file.. example

Save (..., ..., ..., Count);

system("PAUSE");

            return 0;

}

Explanation / Answer

#include<iostream>
#include<string>
#include<fstream>

using namespace std;
void ReadFile(int property[], int bedroom[], double price[], int &count)
{
ifstream file("realestate.txt");
//Open ticketmastere text file.
if (file)
{
while (!file.eof())
{
file >> property[count];
file >> bedroom[count];
file >> price[count];
count++;
}
file.close();

cout << "File Opened ...." << endl;

}
else
{
cout << "File Cannot be Opened....." << endl;
}

}

void writeFile(int property[], int bedroom[], double price[], int count)
{
//writing the information back to the file
ofstream fileOut("realestate.txt");
fileOut << count;
for (int i = 0; i < count; i++)
{
fileOut << endl << property[i] << " " << bedroom[i] << " " << price[i];
}
fileOut.close();
}
void AddNewProperty(int property[], int bedroom[], double price[], int &count)
{
for (int i = 0; i < count; i++)
{

cout << "What is the property number between 1 to 20000? " << endl;
cin >> property[i];
if (property[i] < 1 || property[i] > 20000)
{
cout << "Error: Property Number cannot be less than 1 and more than 20000:" << endl;
break;
}

cout << "What is the price?" << endl;
cin >> price[i];
if (price[i] < 50000 || price[i] > 10000000)
{
cout << "Error: price cannot be lower than 50000 and more than 10000000" << endl;
break;
}
else
cout << "How many bedroom is it?" << endl;
cin >> bedroom[i];
if (bedroom[i] < 1)
{
cout << "Error: Bedroom cannot be lower than 1" << endl;
break;
}
else

{

cout << "New Property Successfully added " << endl;
break;
}

}
}
void PriceReduction(int property[], int bedroom[], double price[], int &count)
{
int propertyid;
double reductionamount=0;
cout << "Please Enter the property id:" << endl;
cin >> propertyid;
for (int i = 0; i < count; i++)
{
if (property[i] != propertyid)
{
cout << "Property " << propertyid << " does not exits " << endl;
}
else if (property[i] = propertyid)
{
cout << "please Enter the amout of reduction:" << endl;
cin >> reductionamount;
}
price[i] -= reductionamount;

}
}
void Searchproperty(int property[], int bedroom[], double price[], int &count)
{
double maximumprice = 0;
int minimumbedroom = 0;

cout << "Enter the Maximum Price: " << endl;
cin >> maximumprice;
cout << "Enter the Minimum Bedroom Needed: " << endl;
cin >> minimumbedroom;
for (int i = 0; i < count; i++)
{
if ((property[i] >= minimumbedroom) && (price[i] <= maximumprice))
{
cout << "The matched Property id: " << property[i] << " " << "Bedroom: " << bedroom[i] << " Price is: $" << price[i] << endl;
}

else
{
cout << "Sorry Not Available" << endl;
}

break;
}


}
void Report(int property[], int bedroom[], double price[], int count)
{
float avg;
int sum = 0;
for (int i = 0; i < count; i++)
{
cout << endl << "Property ID:" << " " << property[i] << " " << "Bedroom:" << " " << bedroom[i] << " " << "Price:" << "$" << price[i] << endl;
sum += price[i];

}
avg = sum / count;
cout << "Average home price:" << "$" << avg << endl;

}

int main()
{
int property[20000]; // property[0],property[1]...property[19999]
double price[20000]; // price[0],price[1]...price[19999]
int bedroom[20000]; // bedroom[0],bedroom[1]...bedroom[19999]
int count = 0;
for (int i = 0; i < 20000; i++)
{
property[0] = 0;
price[0] = 0;
bedroom[0] = 0;
}

ReadFile(property, bedroom, price, count);

int choice = 1;
while (choice != 5)

{
// Step B: Create a Menu
cout << "REALTOR ASSIST v1.0 " << endl;
cout << "1-New Property" << endl;

cout << "2-Price Reduction" << endl;
cout << "3-Search Property" << endl;
cout << "4-Report" << endl;
cout << "5-Exit" << endl;

cout << "Please Enter your choice:";
cin >> choice;
if (choice == 1)
{
AddNewProperty(property, bedroom, price, count);
}

else if (choice == 2)
{
PriceReduction(property, bedroom, price, count);
}

else if (choice == 3)
{
Searchproperty(property, bedroom, price, count);
}
else if (choice == 4)
{
Report(property, bedroom, price, count);
}

else if (choice == 5)
{
break;
}


}
// write new info. into the file.
writeFile(property, bedroom, price, count);


system("pause");
return 0;
}