我正在尝试编写一个程序,该程序将返回特定整数美分的零钱。例如 92 美分将返回:0 美元、3 个 25 美分、1 毛钱、1 镍币和 2 便士。
这是我到目前为止的代码:
#include <iostream>
using namespace std;
int main() {
// 1. ask user to enter an integer: total cents
cout << "Hi! Enter an integer representing the total number of cents pls: " << endl;
int user_num{};
// 2. save in std cin
cin >> user_num;
// 3. check dollars
int dollars{};
int add_to_dollars{};
if ( user_num >= 100 ) { // eg. user_num is 240
// calculate amount …Run Code Online (Sandbox Code Playgroud)