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

List of all available Websheets


Viewing cpp/conditionals/daysofmonth 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>Days of month:</p>
<ol>
   <li>The bill must pass the House of Representatives</li>
   <li>The bill must pass the Senate</li>
   <li>The bill must not be vetoed by the President</li>
   <li>The bill must be vetoed by the President but then overridden by Congress
      with 2/3 vote</li>
</ol>
<p></p>
<p>Write a program to determine if a bill becomes law based on the 
   Boolean results of the above conditions.</p>
<p>Output <tt>passed</tt> or <tt>not passed</tt>, followed by a newline
   to the screen.</p>
Public permissions remove
Remarks
Comments, history, license, etc.
 
Copied from problem cpp/conditionals/bill2law (author: redekopp@usc.edu)
Copied from problem cpp/conditionals/instock (author: redekopp@usc.edu)
Copied from problem cpp/conditionals/taxbrackets (author: redekopp@usc.edu)
Copied from problem cpp/conditionals/nestedec (author: redekopp@usc.edu)
Copied from problem cpp/conditionals/extracredit (author: redekopp@usc.edu)
Copied from problem cpp/control/flag (author: daveagp@gmail.com)
remove
Engine
Template / Reference solution
 
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
   bool housePassed, senatePassed, vetoed, overridden;
   
   cin >> housePassed >> senatePassed >> vetoed >> overridden;
   \[
   if( housePassed && senatePassed && (!vetoed || (vetoed && overridden) ) )
   {
      cout << "passed" << endl;
   }
   else 
   {
      cout << "not passed" << 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 1 0 1", "args": ""},
   {"stdin": "1 0 0 1", "args": ""},
   {"stdin": "1 1 0 0", "args": ""},
   {"stdin": "1 1 1 0", "args": ""},
   {"stdin": "1 1 1 1", "args": ""}
]
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'.