Im storing prices in pennies e.g 399 but i want it to be displayed e.g £3.99p
how to do ? i used integers?
jbennet
1,618
Most Valuable Poster
Team Colleague
Featured Poster
Recommended Answers
Jump to PostThis would do it
int total = 399; System.out.printf("\u00a3%1$d.%2$dp%n", total/100, total%100);
Jump to PostWouldn't this do it for you?
int pound = price / 100; int pennies = price % 100; System.out.println("Price "+pound + "." + pennies); //OR System.out.println("Price "+ price/100 + "." + price%100);
All 7 Replies
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
jbennet
1,618
Most Valuable Poster
Team Colleague
Featured Poster
BestJewSinceJC
700
Posting Maven
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
BestJewSinceJC
700
Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.