26.8.15

Design your own manipulator

Design your own manipulator to provide the following output specification for printing money value:
1)  10 columns width

2)  The character '$' at the beginning

3)  Showing '+' sign.

4)  Two digits precision

5)  Filling of unused spaces with ' * '

6)  Trailing zeros shown


#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

ostream &moneyshow(ostream &output)

{

cout<<'$'; cout.fill('*');

cout.setf(ios::showpos);

cout.setf(ios::showpoint);

cout.width(10);

cout.precision(2); return output;

}

void main()

{

double amount; clrscr();

cout<<"enter the value:"; cin>>amount;

cout<<"\nyour money value:"; cout<<moneyshow<<amount; getch();

}

  


*************************OUTPUT 1***************************************

enter the value:12.2

your money value:$****+12.20

*************************OUTPUT 2***************************************

enter the value:34

your money value:$****+34.00

No comments:

Post a Comment

Comment Here