Writing a code for problem

June 16, 2009 at 17:31:00
Specs: Windows XP
I need to design a program that inputs a number of cents (0-99) and output the minimal number of 1 cents, 5 cents, 10 cents and 25 cents. I need some ideas of how to approach the problem

See More: Writing a code for problem

Report •


#1
June 16, 2009 at 17:52:52
divide the number by 25 , see how many 25's there are, store it. do the same of the remainders by divide by 10, 5, 1,etc.

GNU win32 packages | Gawk


Report •

#2
June 16, 2009 at 18:07:26
Choosing a programming language might be a real good first step.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#3
June 16, 2009 at 21:08:21
I have choosen c++

this is how i start the code

#include <iostream>
using namespace std;
int main ()
{
float cents;
float balance =0.99;
cout<< "Please enter number of cents \n";
cin>> cents;
if(cents <= 0.99){
balance=balance-cents;
cout<<"Your remaining balance is = "<<balance <<endl;
}else if(cents > 0.99){
cout<<"You have exceeded your balance\nplease enter amount less than 0.99 \n";
}system ("PAUSE");
return 0;
}

To break it down in 25, 20, 5 ,1 i am lost in doing this.
Can somone suggest what my code is missing to break down the out put in the above format??


Report •

Related Solutions

#4
June 16, 2009 at 22:37:20
I'm no programmer, but the first thing I noticed is: why is cents float?


=====================================
If at first you don't succeed, you're about average.

M2


Report •


Ask Question