473,691 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1445
Oh, I have an idea, should I convert the ints into floats for display
purposes?

Is that the only way?

"mchoya" <mi******@sbcgl obal.net> wrote in message
news:0p******** ********@newssv r17.news.prodig y.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******@sbcgl obal.net> wrote in message
news:QC******** ********@newssv r17.news.prodig y.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******@sbcgl obal.net> wrote in message news:0p******** ********@newssv r17.news.prodig y.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************* **********@hotm ail.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************ ***********@hot mail.com> wrote in message
news:aI******** ********@news.u swest.net...
"mchoya" <mi******@sbcgl obal.net> wrote in message
news:QC******** ********@newssv r17.news.prodig y.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******@sbcgl obal.net> wrote in message
news:0p******** ********@newssv r17.news.prodig y.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************* **********@hotm ail.com
Above views may belong only to me.

Jul 23 '05 #4
"mchoya" <mi******@sbcgl obal.net> wrote in message
news:YT******** ********@newssv r17.news.prodig y.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::istringstr eam 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************ ***********@hot mail.com> wrote in message news:aI******** ********@news.u swest.net...
"mchoya" <mi******@sbcgl obal.net> wrote in message
news:QC******** ********@newssv r17.news.prodig y.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******@sbcgl obal.net> wrote in message news:0p******** ********@newssv r17.news.prodig y.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************* **********@hotm ail.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
1918
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 a table. Any ideas?
10
1881
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 add more than one to a page. 2. Also need to add the two results to a 'total' field. (See code attached). Many thanks in advance.
3
4794
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 11.95 12.55 13.76 1500 ¦ 11.23 12.23 13.45 14.45
1
1114
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
1994
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, System.Web.UI.WebControls.DataGridItemEventArgs e) { DataRowView rowData; decimal price; decimal priceWk; decimal newssum;
1
1652
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 he does all the Html and code within one file. For example normally we create an ASP.net application we will have the choice of doing the design in the design view and the code in the code view. This was not the case, he did both in the same file...
3
4741
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 even sure if the way I've written this is going to work but anyway, I keep getting a compilation error that says: C:\Documents and Settings\Sam\GUICDInventory.java:22: cannot find symbol symbol : constructor JList(CDInventory) location: class...
1
1399
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 = ls1Level & Trim(rsMn.Fields("PRICE")) & Space(8 - Len(Trim(rsMn.Fields("PRICE")))) and the value in ls1Level= " 1 TSNL 204" here 204 is the price of any item "TSNL" having serial no 1 how can i insert the format function in the above line
3
2341
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
0
8599
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9079
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8791
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4322
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2966
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1954
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.