d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso C++ Help
Add Reply New Topic New Poll
Member
Posts: 8,271
Joined: May 20 2006
Gold: 0.00
Jan 28 2025 03:23pm
so I was starting to write my first program

I want to feed how many coins are in 25 cents
2 dimes 1 nickel
3 nickels 1 dime
5 nickles
1 quarter

This is my first project any help is appreciated
Member
Posts: 8,658
Joined: Jun 19 2018
Gold: 259.00
Feb 4 2025 07:52pm
Yeah this is easy you need to start with a for(loop) and start off with the largest cents and then reduce


example:

**Total in the argument would be your "25 cents" that you could change to whatever value you wanted.
int coinsTotal(int total){
int quarter = 25;
int dime = 10;
int nickel = 5;
int penny = 1;
int sum = 0;
Then create a SUM variable to check vs value
int sum = 0;
For(int i = 0; i < total; i++){
**Enter arguments here**
!! Important to start with larger coins to avoid looping issues
1. Quarter
2. dimes
3. nickels
4. Pennies
Go in that order
Then you can make additional sum_ONE to either hold values or cout << statements

There are many many other ways to program this but this will be the "Most basic" way to approach this.

Member
Posts: 8,271
Joined: May 20 2006
Gold: 0.00
Feb 5 2025 03:32pm
tyvm in the works
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll