Ok, I need Help using c++ including fstream to solve this assignment.

{a C++ program that generates all the possible representations of N cents in the typical

American coins: quarters (25 cents), dimes (10 cents), nickels (5 cents), and pennies (1 cent). The

number of cents N must be a positive integer read from the keyboard.

Example: The sum of N = 20 cents can be represented as 2 dimes; or 1 dime and 2 nickels; or

1 dime, 1 nickel, and 5 pennies; or 6 other combinations of coins.

The representations must be written in a text file, one representation per line. The exact format

of a representation will be decided by you, but it must be clear to understand (that is, it must

contain the numbers of each type of coin used in the representation).

The name of the text file will contain the number of cents N. For instance, if you generate the

representations of 20 cents, the name of the text file must be Representations 20cents; if you gen-

erate the representations of 500 cents, the name of the text file must be Representations 500cents;

and so on.

Please note that the number of representations grows fast with N: for instance, one can repre-

sent 100 cents in 242 ways; 1000 cents can be represented in 142,511 ways. Therefore, your output

file can be pretty large.

Hint: You may write a recursive function that generates the representations of N cents.}

any suggestions. I need to submit it by today and I dont understand the fstream. so I cant solve it.

{a C++ program that generates all the possible representations of N cents in the typical

American coins: quarters (25 cents), dimes (10 cents), nickels (5 cents), and pennies (1 cent). The

number of cents N must be a positive integer read from the keyboard.

Example: The sum of N = 20 cents can be represented as 2 dimes; or 1 dime and 2 nickels; or

1 dime, 1 nickel, and 5 pennies; or 6 other combinations of coins.

The representations must be written in a text file, one representation per line. The exact format

of a representation will be decided by you, but it must be clear to understand (that is, it must

contain the numbers of each type of coin used in the representation).

The name of the text file will contain the number of cents N. For instance, if you generate the

representations of 20 cents, the name of the text file must be Representations 20cents; if you gen-

erate the representations of 500 cents, the name of the text file must be Representations 500cents;

and so on.

Please note that the number of representations grows fast with N: for instance, one can repre-

sent 100 cents in 242 ways; 1000 cents can be represented in 142,511 ways. Therefore, your output

file can be pretty large.

Hint: You may write a recursive function that generates the representations of N cents.}

any suggestions. I need to submit it by today and I dont understand the fstream. so I cant solve it.

Topic archived. No new replies allowed.