473,856 Members | 1,750 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 1460
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
1925
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
1898
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
4805
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
1120
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
2004
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
1656
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
4765
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
1410
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
2363
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
9758
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11051
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...
0
10693
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10773
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
10378
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9527
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...
1
7929
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7087
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
5756
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...

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.