This is a discussion on got some error on the PrintResult,,tell me how to change it! within the C and C++ forums, part of the Programming Talk category; #include <stdio.h> int main(); int getData() { int totalChange; printf("Please enter amount of change:"); scanf("%d", &totalChange); return(totalChange); } int errorResult(int ...
|
|||||||
|
|||
|
got some error on the PrintResult,,tell me how to change it!
#include <stdio.h>
int main(); int getData() { int totalChange; printf("Please enter amount of change:"); scanf("%d", &totalChange); return(totalChange); } int errorResult(int totalChange) { const int MaxChange = 95; const int MinChange = 5; int valid; if(totalChange > MaxChange || totalChange < MinChange) { printf("Please enter the number between 5 and 95: \n"); valid = 0; } return(valid); } float makeChange(int *totalChange, int cent) { int number = 0; int newChange; float change; int dollar; int cents; newChange =(*totalChange % cent); number =(*totalChange - newChange)/cent; *totalChange = newChange; dollar = (int) change; cents = (int) (((change - dollar)*100) + 0.5); return(number); } void PrintResult(int number, int cents, int Dollar) { printf("%dc = %d\n", Dollar, number); return; } int main() { int totalChange, fiftyc, twentyc, tenc, fivec, valid; int hundredd, fiveZerod, twoZerod, oneZerod, ZeroFived, ZeroTwod, ZeroOned; const int FiftyCents = 50; const int TwentyCents = 20; const int TenCents = 10; const int FiveCents = 5; const int HundredDollars = 100; const int FiveZeroDollars = 50; const int TwoZeroDollars = 20; const int OneZeroDollars = 10; const int zeroFiveDollars = 5; const int zeroTwoDollars = 2; const int zeroOneDollars = 1; totalChange = getData(); valid = errorResult(totalChange); if(valid) { fiftyc = makeChange(&totalChange, FiftyCents); twentyc = makeChange(&totalChange, TwentyCents); tenc = makeChange(&totalChange, TenCents); fivec = makeChange(&totalChange, FiveCents); hundredd = makeChange(&totalChange, HundredDollars); fiveZerod = makeChange(&totalChange, FiveZeroDollars); twoZerod = makeChange(&totalChange, TwoZeroDollars); oneZerod = makeChange(&totalChange, OneZeroDollars); ZeroFived = makeChange(&totalChange, zeroFiveDollars); ZeroTwod = makeChange(&totalChange, zeroTwoDollars); ZeroOned = makeChange(&totalChange, zeroOneDollars); PrintResult(makeChange(totalChange, FiftyCents), FiftyCents); PrintResult(makeChange(totalChange, TwentyCents), TwentyCents); PrintResult(makeChange(totalChange, TenCents), TenCents); PrintResult(makeChange(totalChange, FiveCents), FiveCents); PrintResult(makeChange(totalChange, HundredDollars), HundredDollars); PrintResult(makeChange(totalChange, FiveZeroDollars), FiveZeroDollars); PrintResult(makeChange(totalChange, TwoZeroDollars), TwoZeroDollars); PrintResult(makeChange(totalChange, OneZeroDollars), OneZeroDollars); PrintResult(makeChange(totalChange, zeroFiveDollars), zeroFiveDollars); PrintResult(makeChange(totalChange, zeroTwoDollars), zeroTwoDollars); PrintResult(makeChange(totalChange, zeroOneDollars), ZerOneDollars); } return(0); } |
| Sponsored Links |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Top 5 Reasons Why You Need a Career Change | lokeshm | Career Advice | 0 | 01-31-2007 06:19 AM |
| Change Password for SQL Server User | admin | SQL Server 2005 Tutorials | 2 | 04-07-2006 12:09 PM |
| Solaris x86 FAQ 2/2 | Dan Anderson | Tech FAQ | 0 | 04-27-2004 08:24 PM |
| Quarterly ASCII posting of Caldera (SCO) OpenUNIX 8 FAQ | Boyd Lynn Gerber | Tech FAQ | 0 | 04-25-2004 11:11 PM |
| Kerberos FAQ, v2.0 (last modified 8/18/2000) | Ken Hornstein | Tech FAQ | 0 | 04-17-2004 08:28 AM |