answersLogoWhite

0


Best Answer

Denomination values should be stored in an integer array where each value is in pennies. So $100 is 10000 pennies:

const array<int,10> value = {10000, 5000, 2000, 500, 100, 50, 25, 10, 5, 1};

Create a parallel array with the actual denominations:

const array<string,10> denomination = {"hundreds", "fifties", "twenties", "fives", "dollars", "half", "quarters", "dimes", "nickels", "cents"};

Start by multiplying the amount by 100 to determine the actual number of pennies. So $1.23 becomes 123 pennies. Store this value as an integer named pennies.

Now work your way through the denominations in sequence:

for (int index=0; index<value.size() && pennies; ++index)

{

int number=pennies/value[index];

if (number)

cout<<number<<' '<<denomination[index]<<endl;

pennies%=value[index];

}

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a java program in which the user will enter an amount of money as a decimal number and the program will compute how many pennies nickels dimes quarters ones fives tens twenties etc.?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

7.25 in quarters and nickels there are 5 more quarters than nickels how many quarters and nickels are there?

25 quarters, 20 nickels.


What is the ratio of 7 nickels to 2 quarters?

The easiest way is to convert everything to cents first. - Seven nickels = 35 cents - Two quarters = 50 cents - so 7 nickels to 2 quarters is the same as 35/50, or 0.7 as a decimal number.


How many ways can you get 4.10 with only quarters and nickels?

There are 11 ways to get $4.10 using only quarters and nickels. These combinations are: 41 quarters 8 quarters, 6 nickels 15 quarters, 2 nickels 3 quarters, 12 nickels 20 quarters, 1 nickel 35 quarters 8 quarters, 5 nickels 15 quarters, 1 nickel 5 quarters, 10 nickels 30 quarters, 1 nickel 1 quarter, 20 nickels


Jane has some nickels dimes and quarters which total 1.90 She has twice as many quarters as dimes she has three times as many quarters as nickels how many quarters does she have?

Peggy had three times as many quarters as nickels. She had $1.60 in all. How many nickels and how many quarters did she have?


In a group of quarters and nickels there are four more nickels than quarters How many nickels and quarters are there if the coins are worth 2.30?

7 quarters and 11 nickles


How many nickels are in fourteen quarters?

how many quarters are in 40 nickels


How would you solve in a group of quarters and nickels there are four more nickels than quarters how many nickels and quarters are there if the coins are worth 2.30?

7 quarters = 1.7511 nickels = 0.551.75 + 0.55 = 2.30


Carmen has 2.80 in nickels and quarters She has twice as many nickels as quarters How many of each kind of coin does she have?

8 quarters and 16 nickels


How many quarters and nickels are in3.10?

$3.10 could be no quarters and 62 nickels, or it could be 12 quarters and 2 nickels, or it could be eleven other different mixes. There are 13 different ways to do it with quarters and nickels.


How many nickels does 5 quarters equal?

5 quarters * 5 nickels/quarter = 5 * 5 nickels = 25 nickels


How many quarters and nickels are worth 4.95?

19 quarters and 4 nickels.


Eric has 130 coins consisting of nickels and quarters. The coins' combined value is 15.90. How many are nickels and how many are quarters?

47 Quarters 83 Nickels