Home › Forums › C Programming › Banking › Re: Re: Banking
December 1, 2008 at 7:35 pm
#3486
GWILouisaxwzkla
Participant
Could do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <br /> /****************************************************************<br /> * File Name : c:programstempcg.cpp<br /> * Date : December,1,2008<br /> * Comments : new project<br /> * Compiler/Assembler :<br /> *<br /> *<br /> *<br /> *<br /> *<br /> * Program Shell Generated At: 2:09:49 p.m.<br /> =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /> <br /> <br /> #include <br /> //#include <br /> //#include <br /> //#include <br /> //#include <br /> //#include <br /> <br /> using namespace std;<br /> <br /> <br /> //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@<br /> <br /> <br /> <br /> //##################################################################################<br /> <br /> <br /> //main function ******************************<br /> <br /> int main ( )<br /> {<br /> <br /> cout << "Enter change amount : ";<br /> float change;<br /> cin >> change;<br /> <br /> int hundreds = 0;<br /> int fifties = 0;<br /> int tens = 0;<br /> int tempChange = change;<br /> <br /> while ( tempChange >= 100 )<br /> {<br /> hundreds ++;<br /> tempChange -= 100;<br /> }<br /> <br /> tempChange = change;<br /> while ( tempChange >= 50 )<br /> {<br /> fifties ++;<br /> tempChange -= 50;<br /> }<br /> <br /> tempChange = change;<br /> while ( tempChange >= 10 )<br /> {<br /> tens ++;<br /> tempChange -= 10;<br /> }<br /> <br /> cout << "you can change " << change << " with: " << endl;<br /> cout << hundreds << " hundreds" << endl;<br /> cout << fifties << " fifties " << endl;<br /> cout << tens << " tens" << endl;<br /> <br /> <br /> return 0 ;<br /> }<br /> <br /> |
output:
1 2 3 4 5 6 7 8 9 | <br /> Enter change amount : 200<br /> you can change 200 with:<br /> 2 hundreds<br /> 4 fifties<br /> 20 tens<br /> Press any key to continue<br /> <br /> |