List of all available Websheets
Viewing cpp/var-expr/change by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | <p>Write a program that accepts an integer value from 00-99 representing <strong>cents</strong> then output how you would make that much change using quarters, dimes, nickels, and pennies if you gave as many of the largest denominations first (without going over) before moving to lower denominations.</p> <p><em>Hint:</em> Think about how to use division and modulo operations.</p> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/cin/deg2rad (author: redekopp@usc.edu) Copied from problem cpp/var-expr/in_n_days (author: redekopp@usc.edu) Copied from problem cpp/var-expr/char_arith (author: redekopp@usc.edu) Copied from problem cpp/var-expr/hello (author: daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; int main() { int cents; int quarters; int dimes; int nickels; int pennies; cout << "Enter how many cents to convert: " << endl; cin >> cents; \[ quarters = cents / 25; cents = cents % 25; // or cents = cents - 25*quarters; dimes = cents / 10; cents = cents % 10; // or cents = cents - 10*dimes; nickels = cents / 5; pennies = cents % 5; // or cents = cents - 5*nickels; ]\ cout << "Quarters: " << quarters << endl; cout << "Dimes: " << dimes << endl; cout << "Nickels: " << nickels << endl; cout << "Pennies: " << pennies << endl; return 0; } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {"stdin":"0", "args":[]}, {"stdin":"99", "args":[]}, {"stdin":"73", "args":[]}, {"stdin":"30", "args":[]}, {"stdin":"20", "args":[]} ] |
Solution visibility |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.