List of all available Websheets
Viewing cpp/var-expr/in_n_days 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>Ask the user to enter an integer indicating which day of the week it is (Sun. = 1, Mon. = 2, ..., Sat. = 7) and another integer, <tt>n</tt> for many days will pass.</p> <p>Then output which day of the week it will be (again use <tt>1-7</tt> for Sun. through Sat.) after the <tt>n</tt> days will pass.</p> |
Public permissions | |
Remarks Comments, history, license, etc. | 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() { // variable for the current day and how many will pass int cday, n; cout << "Enter what day of the week it is" << " (Sun.=1, Mon.=2, ..., Sat.=7)?" << endl; \[ cin >> cday; ]\ cout << "Enter how many days will pass: " << endl; \[ cin >> n; int day_plus_n = 1 + (cday - 1 + n) % 7; ]\ cout << "In " << n << " days it will be weekday: " << day_plus_n << 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":"5 3", "args":[]}, {"stdin":"1 7", "args":[]}, {"stdin":"3 16", "args":[]}, {"stdin":"7 1", "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'.