List of all available Websheets
Viewing cpp/arrays/weekday 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>Terry Trojan setup a (somewhat random) schedule for how long he should exercise each day of the week and now wants to create a program where he can enter the day of the week (1 = Sunday to 7 = Saturday) and have the program tell him how long he must exercise.</p> <p>The program should keep taking input days <tt>1-7</tt> until the user enters <tt>0</tt>. Do not worry about other inputs.</p> <p>The exercise times are shown in the table below </p> <table border="1"> <tr><th>Day</th><th>Duration</th><th>Day</th><th>Duration</th></tr> <tr><td>Sunday</td><td>40</td> <td>Thursday</td><td>30</td> </tr> <tr><td>Monday</td><td>55</td> <td>Friday</td><td>25</td> </tr> <tr><td>Tuesday</td><td>60</td> <td>Saturday</td><td>18</td> </tr> <tr><td>Wednesday</td><td>47</td> <td></td><td></td> </tr> </table> <p>So given the input: <tt>4 6 1 0</tt> </p> <p>The output should be:</p> <pre> 47 18 40 </pre> <p>Notice no prompt or other output text beyond the exercise duration is necessary.</p> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/arrays/cipher (author: redekopp@usc.edu) Copied from problem cpp/arrays/examples/arraybad (author: redekopp@usc.edu) |
Engine | |
Template / Reference solution |
using namespace std; int main() { \[ int duration[7] = {40, 55, 60, 47, 30, 25, 18}; int day; cin >> day; while(0 != day){ cout << duration[day-1] << endl; cin >> day; } ]\ 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":"4 6 1 0"}, {"stdin":"7 6 5 4 3 2 1 2 3 4 5 6 7 0"} ] |
Solution visibility | |
Is example? i.e., just a demo | |
Add compiler flag(s) json list of flags e.g. ["-Wno-unused-variable"] | ["-Wno-array-bounds"] |
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'.