Jan 7, 2010 at 10:22pm UTC
I'm newbie here...I want to make my out to be like this
Television.............................RM2398.00
DVD Player............................RM 350.00
Biscuits...................................RM 31.50
*******************************
Total.....................................RM2779.50
using iomanip header but, every time I compile it. it not become how it to be.. :(
here is my source code
#include<iostream>
#include<iomanip>
using namespace std;
int main(void)
{
double tv = 2398, dvd = 250, bis =31.5, total;
total = tv+dvd+bis;
cout<<setw(22)<<setfill(' ')<<left<<"Item"<<""<<setw(7)<<setfill(' ')<<right<<"Price"<<endl;
cout<<setw(22)<<setfill('.')<<left<<"Television"<<"RM"<<setw(7)<<setfill(' ')<<right<<tv<<""<<endl;
cout<<setw(22)<<setfill('.')<<left<<"DVD Player"<<"RM"<<setw(7)<<setfill(' ')<<right<<dvd<<""<<endl;
cout<<setw(22)<<setfill('.')<<left<<"Biscuits"<<"RM"<<setw(7)<<setfill(' ')<<right<<bis<<""<<endl;
cout<<setw(31)<<setfill('*')<<""<<endl;
cout<<setw(22)<<setfill('.')<<left<<"Total"<<"RM"<<setw(7)<<setfill(' ')<<right<<total<<""<<endl;
return 0;
}
Last edited on Jan 10, 2010 at 6:40pm UTC
Jan 8, 2010 at 4:45am UTC
I tried compiling your code and it works fine with me.
What is your output?
Jan 8, 2010 at 10:50pm UTC
Item Price
Television............RM 2398
DVD Player............RM 250
Biscuits..............RM 31.5
*******************************
Total.................RM 2679.5
this is my output...but i want it be like this
Item Price
Television.............................RM2398.00
DVD Player............................RM 350.00
Biscuits...................................RM 31.50
*******************************
Total.....................................RM2779.50
Jan 10, 2010 at 7:03pm UTC
Can you put the actual/expected results in [out put][/output] tags?
Otherwise multiple spaces are lost in your post and we can't know what is the result you want
Jan 15, 2010 at 5:09pm UTC
emm just want to asking. How about showpoint