Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/functions/wakeup by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
<p>Write a function that outputs a message indicating whether you need to wake up early or can sleep in
   based on the day of the week.  Assume, the user passses the day of the week (1=Sunday, 2=Monday, 7=Saturday).
   Of course <strong>on M,W when you have CS 102 you wake up early</strong>. Other days you can sleep in.</p>
<p>Complete the function, outputting either <tt>Wake up early</tt> or <tt>Sleep in</tt>.</p>
Public permissions remove
Remarks
Comments, history, license, etc.
 
Copied from problem cpp/functions/hypotenuse (author: redekopp@usc.edu)
Copied from problem cpp/functions/abs_func (author: redekopp@usc.edu)
remove
Engine
Template / Reference solution
 
#include <iostream>
\hide[
#include <string>
   ]\
using namespace std;
// write the prototype below
\[ void wakeup( int day ); ]\ 
// test it
int main() 
{
   int day_of_week;
   cin >> day_of_week;
   
   \[
      wakeup(day_of_week);
   ]\
   return 0;
}
\[void ]\ wakeup(\[ int day ]\) 
{
\[
   if(day == 2 || day == 4)
   {
      cout << "Wake up early" << endl;  
   }
   else 
   {
      cout << "Sleep in" << endl;  
   }
]\
} 
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" : "1"},
   {"stdin" : "2"},
   {"stdin" : "3"},
   {"stdin" : "4"}
]
Solution visibility remove


Optional properties:

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'.