That's not working either, or I'm not using them right. Here is how I am
using them now:
I have also used them where the outData << left and outData << right are.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
//declare file stream variables
ofstream outData;
//declare variables
double value, taxAmt, propTax;
double tax = 0.92, rate = 1.05;
setiosflags(ios_base::right);
resetiosflags( ios_base::left );
//open the output file
outData.open("m:\\review\\chapter 3\\exercise 4\\houseData.txt");
//get the assessed value
cout << "Enter the Assessed Value of the property: ";
cin >> value;
cout << endl;
//calculate values
taxAmt = value * tax;
propTax = (taxAmt / 100) * rate;
//begin outputting data
outData << "Assessed Value:";
outData << right;
outData << value << endl;
outData << left;
outData << "Taxable Amount:";
outData << right;
outData << taxAmt << endl;
outData << left;
outData <<"Tax Rate for each $100:";
outData << right;
outData << rate << endl;
outData << left;
outData <<"Property Tax:";
outData << right;
outData << propTax << endl;
//end the program
cout << "File created. Ending the program." << endl;
return 0;
}
"Moonlit" <news moonlit xs4all nl> wrote in message
news:43***********************@news.xs4all.nl...
Hi,
Yes, the famous reset/set problem
setiosflags( ios_base::right ) << resetiosflags( ios_base::left )
--
Regards, Ron AF Greve
http://moonlit.xs4all.nl
"deanfamily11" <de**********@verizon.net> wrote in message
news:Wx4Te.2918$AB4.357@trnddc03... Ok, here's another problem I'm having. I've tried several different
things, but I just can't get anything to be right justified. Any
thoughts?
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
//declare file stream variables
ofstream outData;
//declare variables
double value, taxAmt, propTax;
double tax = 0.92, rate = 1.05;
outData.setf(ios::right);
outData.setf(ios::left);
//open the output file
outData.open("c:\\review\\chapter 2\\exercise 4\\houseData.txt");
//get the assessed value
cout << "Enter the Assessed Value of the property: ";
cin >> value;
cout << endl;
//calculate values
taxAmt = value * tax;
propTax = (taxAmt / 100) * rate;
//begin outputting data
outData << "Assessed Value:";
outData << right;
outData << value << endl;
outData << left;
outData << "Taxable Amount:";
outData << right;
outData << taxAmt << endl;
outData << left;
outData <<"Tax Rate for each $100:";
outData << right;
outData << rate << endl;
outData << left;
outData <<"Property Tax:";
outData << right;
outData << propTax << endl;
//end the program
cout << "File created. Ending the program." << endl;
return 0;
}