Jump to content

# Representing money and keeping track

## Recommended Posts

Hello  All I am working on a application where I have to represent money and display how many bills were used to make each amount. I can do this The only problem I am working on figuring out is recording the number of each bill that has been used and to subtract it for the current number. I was thinking of making a money class for 100s 50s 20s 10s 5s and 1s but  I cant have each value bill with a specified number of how many. Having the value specificed I would have this : but each one of these has no value amount

```	     int hund = 10;
int fif = 10;
int twen = 10;
int ten = 10;
int five = 10;
int one = 10;
```

Or if I want a value amount I was thinking this But I cant determine a fixed number to use

```	    public class Money
{
public int HundBill { get; set; }
public int FiftBill { get; set; }
public int TwentBill { get; set; }
public int TenBill { get; set; }
public int FiveBill { get; set; }
public int OneBill { get; set; }

public Money()
{
HundredDollarBill = cash / 100;
cash %= 100;
FiftyDollarBill = cash / 50;
cash %= 50;
TwentyDollarBill = cash / 20;
cash %= 20;
TenDollarBill = cash / 10;
cash %= 10;
FiftyDollarBill = cash / 5;
cash %= 5;
OneDollarBill = cash / 1;
cash %= 1;      }
```

I am getting the users input and Ill get a number and I want to minus the number of bills that were used to make that amount and to keep track.

##### Share on other sites

Instead of separate variables, use an array whose key is the face value of the bill and the array values are the quantities. The amount for each type of bill would be the key * qty.

##### Share on other sites

This thread is more than a year old.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×

• #### Activity

• Chat
×
• Create New...

## Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.