472,378 Members | 1,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

displaying ints in price form

Hello all,

I want to display a list of ints for example 100, 1000, 10000 as prices
$1.00, $10.00, $100.00.

Can I do this?

I guess I have to use the iomanip lib. But the only manipulators I know
deal with floats.

Thanks, I'll keep trying.
Jul 23 '05 #1
4 1395
Oh, I have an idea, should I convert the ints into floats for display
purposes?

Is that the only way?

"mchoya" <mi******@sbcglobal.net> wrote in message
news:0p****************@newssvr17.news.prodigy.com ...
Hello all,

I want to display a list of ints for example 100, 1000, 10000 as prices
$1.00, $10.00, $100.00.

Can I do this?

I guess I have to use the iomanip lib. But the only manipulators I know
deal with floats.

Thanks, I'll keep trying.

Jul 23 '05 #2
"mchoya" <mi******@sbcglobal.net> wrote in message
news:QC****************@newssvr17.news.prodigy.com ...
Oh, I have an idea, should I convert the ints into floats for display purposes?
I would not unless you truly wish to represent
fractional quanties of money not restricted to
multiples of some unit such as the cent.
Is that the only way?
For any problem, there are usually many
solutions. This is one of the usual cases.
"mchoya" <mi******@sbcglobal.net> wrote in message news:0p****************@newssvr17.news.prodigy.com ...
Hello all,

I want to display a list of ints for example 100, 1000, 10000 as prices $1.00, $10.00, $100.00.

Can I do this?
I would suppose so. A computer can certainly
be made to do it.
I guess I have to use the iomanip lib. But the only manipulators I know deal with floats.


You might find it easier to just use integer division
and the modulo operator to break your quantities
into dollar and cent components, then print them
out with whatever other punctuation you like.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Jul 23 '05 #3
Thanks, I tried that. It does not display the last zero in for example 100
to $1.00.
"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:aI****************@news.uswest.net...
"mchoya" <mi******@sbcglobal.net> wrote in message
news:QC****************@newssvr17.news.prodigy.com ...
Oh, I have an idea, should I convert the ints into floats for display
purposes?


I would not unless you truly wish to represent
fractional quanties of money not restricted to
multiples of some unit such as the cent.
Is that the only way?


For any problem, there are usually many
solutions. This is one of the usual cases.
"mchoya" <mi******@sbcglobal.net> wrote in message
news:0p****************@newssvr17.news.prodigy.com ...
Hello all,

I want to display a list of ints for example 100, 1000, 10000 as prices
$1.00, $10.00, $100.00.

Can I do this?
I would suppose so. A computer can certainly
be made to do it.
I guess I have to use the iomanip lib. But the only manipulators I know
deal with floats.


You might find it easier to just use integer division
and the modulo operator to break your quantities
into dollar and cent components, then print them
out with whatever other punctuation you like.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

Jul 23 '05 #4
"mchoya" <mi******@sbcglobal.net> wrote in message
news:YT****************@newssvr17.news.prodigy.com ...
Thanks, I tried that. It does not display the last zero in for example 100 to $1.00.

#include <iostream>
#include <sstream>

int main(int an, char *ap[])
{
while (an-- > 1) {
std::istringstream iss(ap++[1]);
unsigned ds = 0;
iss >> ds;
unsigned dollars = ds/100;
unsigned cents = ds%100;
std::cout << '$' << dollars << '.';
std::cout.fill('0');
std::cout.width(2);
std::cout << cents << std::endl;
}
}
"Larry Brasfield" <do***********************@hotmail.com> wrote in message news:aI****************@news.uswest.net...
"mchoya" <mi******@sbcglobal.net> wrote in message
news:QC****************@newssvr17.news.prodigy.com ...
Oh, I have an idea, should I convert the ints into floats for display purposes?


I would not unless you truly wish to represent
fractional quanties of money not restricted to
multiples of some unit such as the cent.
Is that the only way?


For any problem, there are usually many
solutions. This is one of the usual cases.
"mchoya" <mi******@sbcglobal.net> wrote in message news:0p****************@newssvr17.news.prodigy.com ...
Hello all,

I want to display a list of ints for example 100, 1000, 10000 as prices $1.00, $10.00, $100.00.

Can I do this?


I would suppose so. A computer can certainly
be made to do it.
I guess I have to use the iomanip lib. But the only manipulators I know deal with floats.


You might find it easier to just use integer division
and the modulo operator to break your quantities
into dollar and cent components, then print them
out with whatever other punctuation you like.


--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.>
Jul 23 '05 #5

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

Similar topics

2
by: Steven | last post by:
Hi there, I have a list of values that I am displaying in a table (Not using a loop) I want to be able to put a graphic next to the item with the hightest price. I have all of the prices in...
10
by: Ed | last post by:
Hoping someone an assist me urgently. I would truly appreciate and help. I have a form and prices are based on 'price break'. 1.The price break fields work fine, but I cannot for the life of me...
3
by: Gigi.com | last post by:
Hi All. I need some help trying to pull prices from a price matrix. Here's an example: >>>> 1000 1500 2000 2500 ----------------------------------------- 1000 10.20 ...
1
by: jomichie | last post by:
Plz Help Me I Have a simple datsbase with 2 tables tblproducts productID primary key productname text unit cost currency tblorder orderID productID
1
by: .Net Sports | last post by:
the below itemdatabound function works , displays all the grand totals in the footer control of the datagrid: private void dglvboard_ItemDataBound(object sender,...
1
by: nesster13 | last post by:
Dear All, I am a new VB programmer and dont know very much about it so please bare with me. Here is the situation. My professor gave us an e-commerce website to work on but the problem is that...
3
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display an array of objects using a GUI. My instructions are that the CD class and it's sublcass don't need to change I just need to modify class CDInventory to include the GUI. I'm not...
1
by: veer | last post by:
hello expert i made a programe in vb6.0 and i want to display the price in decimal format like e.g. 2323.90 i am sending my program line where i want to change the price format ls1Level =...
3
by: M.-A. Lemburg | last post by:
On 2008-08-07 20:41, Laszlo Nagy wrote: 1 It also very fast at dumping/loading lists, tuples, dictionaries, floats, etc. -- Marc-Andre Lemburg eGenix.com
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
0
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.