home *** CD-ROM | disk | FTP | other *** search
- /* FORMIOA.CPP: Using stream manipulators, Part A
-
- The following program will output a grid of floating point
- values with a fixed number of digits which appear to the right
- of the decimal point similar to the way money is written.
- */
-
- #include <iostream.h>
- #include <iomanip.h>
-
- void money(float f) {
- cout.setf(ios::showpoint);
- cout << setw(10) << setprecision(2) << f;
- }
-
- int main(void)
- {
- int i;
- float f;
-
- for ( i = 0, f = 1.50; i < 30; i++, f = f + 32.39) {
- money( f );
- if ( (i % 6) == 5 )
- cout << endl;
- }
- cout << endl;
- for( i = 0; i < 4; i++ )
- money( i );
- cout << endl;
-
- return 0;
- } // end of main()
-
-