c++ question Write a C++ program having as input the sum of money in your wallet, as an integer number read from the keyboard. (You may assume that the wallet cannot contain negative amounts of money.) Your program must compute and print the number of each type of dollar bill (that is, of $1, $5, $10, $20, $50, and $100) in your wallet; also, it must print the total number of banknotes you have.
Think while loops. For example While value_in_wallet > 100 num_of_100s<- num_of_100s + 1 While value_in_wallet > 50 num_of_50s<- num_of_50s + 1 ... total_of_notes = num_of_100s + num_of_50s + num_of_20s + num_of_10s + num_of_5s + num_of_1s As both the number of notes and the number of each type can't be really determined if you have only the sum, I assume this is the more reasonable algorithm.
Nice one across. Didn't quite understand this piece of code though: if (h + f + t + e + i + money != 1) cout << "s"; cout << "." << endl;
I'm a nitpick and added those two extra lines to modify the answer if the guy has one or more bills in his wallet (bill/s).
thank you so much really appreciate it :)
Join our real-time social learning platform and learn together with your friends!