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

List of all available Websheets


Viewing cpp/division-modulo/convert 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
 
You are attempting to create Gordon Ramsay's Horseradish Yorkshire Pudding recipe. <br>
Afraid of being called an 'idiot sandwich', you know that you will likely need many tries before perfecting the dish. <br>
You know that one batch of pudding requires <strong>200 mL</strong> of whole milk. Write a program that takes in the number of times you will
attempt making this dish and then outputs the number of <strong>liters</strong> of milk you will need to purchase. <br>
Assume you can only buy full liters of milk!<br>
Since you are looking for perfection, it is very important that you realize this might take you up to 4 Billion attempts and you 
need to be accurate when you go to the store.
Remarks
Comments, history, license, etc.
 
Copied from problem cpp/cs102/practiceLab4/convert (author: redekopp@usc.edu)
remove
Engine
Template / Reference solution
 
#include <iostream>
#include <cmath>
using namespace std;
int main() 
{
   //hint: Think about what you want to do in terms of "rounding".  
   //       How does this work with fractions, e.g. 200/1000?
   //      There is a library function to do what you want, 
   //       called "ceil()", which rounds to the next higher integer.
   //       For example, ceil(2.1) returns 3.0, ceil(1.9) return 2.0.
   //       But beware that ceil() returns a double.
   //      
   //      However, there is a solution without using ceil() but only
   //       consider that once you have the version working that does
   //       use ceil. (hint: refer to the "sections" exercise)
   unsigned int attempts, liters;
   cin >> attempts;
   \[
REDACTED
]\
   cout << liters << 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", "args":[]},
 {"stdin":"200001", "args":[]},
 {"stdin":"1", "args":[]},
 {"stdin":"23", "args":[]},
 {"stdin":"4000000000", "args":[]}
]


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