Dollar to Coin Value Program

Hi I have an assignment due and I am confused by it. I am currently using Xcode on a Mac to compile a c++ program. My class uses Codeblocks and I am having issues with the variable names and commands.

The assignment is to write a program that calculates the quarters, dimes, nickels, and pennies needed to input the amount of money. We have to apply the largest value coins first and use modulus for the remainder.

the input for turning in is: 398

This is idea I am getting...


#include <iostream>

int input;
int quarters, dimes, nickels, pennies;

cout<<"Enter dollar amount: ";
cin>> input;
quarters = inputquarters/.25;
dimes = (inputDimes%.10)/;
nickels = (inputnickels%.05);
pennies = (inputpennies%.01);
{


Any help you can give is greatly appreciated... Very New to this!
Last edited on
these dont exist in your code ...inputquarters,inputDimes,inputnickels,inputnickels

also your logic is a bit wonky. think what you would do if it was on paper.

quarters = inputquarters/.25; << nice start

but your following sums need to work on what is left over yes? the quarters are already counted.

so...
1
2
3
4
5
quarters = input / 0.25;
input = input - quarters;

dimes = input / 0.10;
input = input - dimes;


hope thats a start for ya. there are nicer ways to do this, but i kept is simple so you can understand how the code should match the real act.
Topic archived. No new replies allowed.