/*************************************************************************
* Name: Malgorzata Fiedziukiewicz CSC 155
* Date: 09/23/2017 Lab 2 Extra Credit
**************************************************************************
* Statement: Determine owner, selling cost and commission for house sale
* Specifications:
* Input -owner (string) and selling price (double), from input file
* Output-owner (string), selling cost (double) and commission (double)
*************************************************************************/
//header files for I/O and string objects
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
//declaration of objects used to store data
string seller; //seller's name
double price; //price of the house
double cost; //cost to sell the house
double commission; //commission on the sale
ifstream inFile; //input (ifstream object)
ofstream outFile; //output (ofstream object)
string fileName; // user defined output file name
//1. Opening the files
inFile.open("Realtor2.txt");
outFile.open(fileName + ".out");
//2. Read from input file
inFile >> seller >> price;
//3. Calculate the cost and the commission
cost = 0.06 * price;
commission = 0.015 * price;
//4. Ask user for fileName
cout << "Please specify output file name ";
cin >> fileName;
cout << endl;
//5. Display results in output file
outFile << fixed << showpoint;
outFile << setprecision(2);
outFile << "This program calculates the cost to sell a home" << endl;
outFile << "and the commission paid to an individual sales agent." << endl;
outFile << endl;
outFile << "Home Owner" << setw(16) << "Price of Home"
<< setw(22) << "Seller's Cost" << setw(20) << "Agent's Commission" << endl;
outFile << left << setw(10) << seller << setfill('*') << right << setw(16) << price
<< setw(22) << cost << setw(20) << commission << endl;
inFile.close();
outFile.close();
return 0;
}