473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Setting Right Alignment

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;

}
Sep 5 '05 #1
3 7014
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;

}

Sep 6 '05 #2
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;

}


Sep 6 '05 #3
Hi,

You are using them wrong.

Here is how it works

The iomanipulators are classes. Now somewhere there is a definition like
this

streamclass( const iomanip& manip )
{
// use flag in manip to manipulate myself

}

So what you have to do is
OutDate << setiosflags( ios_base::left ) << resetiosflags( ios_base::right)
<< poprTax << ...

--
Regards, Ron AF Greve

http://moonlit.xs4all.nl

"deanfamily11" <de**********@verizon.net> wrote in message
news:2t6Te.10349$9q4.3204@trnddc08...
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;

}



Sep 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Craig Thomson | last post by:
How can I have some text aligned to the left of the page and some more text aligned to the right using only CSS without a table? SPAN doesn't have any alignment, and there is only a single DIV...
6
by: Colin Walls | last post by:
I am writing some HTML and CSS that will eventually be produced by a program for running fencing tournaments. Everything is fine apart from column alignment for numbers. Have a look at...
4
by: Shashi | last post by:
Can somebody explain how the byte alignment for structures work, taking the following example and considering: byte of 1 Byte word of 2 Bytes dword of 4 Bytes typedef struct { byte a; word...
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
0
by: Frnak McKenney | last post by:
One of the reasons given for the Allied victory in WWI is that the Nazi armament industry invested so much effort in creating new weapons (e.g. the jet plane) it wasn't able to develop any of them...
7
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
13
by: aegis | last post by:
The following was mentioned by Eric Sosman from http://groups.google.com/group/comp.lang.c/msg/b696b28f59b9dac4?dmode=source "The alignment requirement for any type T must be a divisor of...
4
by: GTi | last post by:
This must be the simplest question on the web. How can I right align text with DrawString ? Normal (left aligned): 1234567890 123456789 12345678 1234567 123456 12345
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.