List of all available Websheets
Viewing cpp/functions/extract-method1 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>Adminstrator Arthur has to write acceptance letters to incoming students. He writes the C++ program shown below.</p> <p></p> <p>Help him simplify how much copy and pasting he needs to do by <strong>extracting a function from the general template</strong> of the form letter. Then call your function multiple times in main.</p> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/functions/etox-fact (author: redekopp@usc.edu) Copied from problem cpp/nestedloops/etox-range (author: redekopp@usc.edu) Copied from problem cpp/for/sum-mult-2-5 (author: redekopp@usc.edu) Copied from problem cpp/for/blastoff (author: redekopp@usc.edu) Copied from problem cpp/while/blastoff (author: redekopp@usc.edu) Copied from problem cpp/while/goldilocks (author: redekopp@usc.edu) Copied from problem cpp/while/sum50 (author: redekopp@usc.edu) Copied from problem cpp/conditionals/rps (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) |
Engine | |
Template / Reference solution |
using namespace std; // Write a prototype for your function here \[ void print_form(string name, int id); ]\ int main() { \[ print_form("Jill", 11111111); print_form("Tommy", 22222222); print_form("Marci", 33333333); print_form("Bryan", 44444444); \show: cout << "Dear Jill," << endl; cout << endl; cout << "Congratulations. We would like to inform you that you have been accepted." << endl; cout << endl; cout << "Your ID number will be 11111111." << endl; cout << endl; cout << "Sincerely," << endl; cout << "USC" << endl; cout << "Dear Tommy," << endl; cout << endl; cout << "Congratulations. We would like to inform you that you have been accepted." << endl; cout << endl; cout << "Your ID number will be 22222222." << endl; cout << endl; cout << "Sincerely," << endl; cout << "USC" << endl; cout << "Dear Marci," << endl; cout << endl; cout << "Congratulations. We would like to inform you that you have been accepted." << endl; cout << endl; cout << "Your ID number will be 33333333." << endl; cout << endl; cout << "Sincerely," << endl; cout << "USC" << endl; cout << "Dear Bryan," << endl; cout << endl; cout << "Congratulations. We would like to inform you that you have been accepted." << endl; cout << endl; cout << "Your ID number will be 44444444." << endl; cout << endl; cout << "Sincerely," << endl; cout << "USC" << endl; ]\ return 0; } // Write the definition of your function here \[ void print_form(string name, int id) { cout << "Dear " << name << "," << endl; cout << endl; cout << "Congratulations. We would like to inform you that you have been accepted." << endl; cout << endl; cout << "Your ID number will be " << id << "." << endl; cout << endl; cout << "Sincerely," << endl; cout << "USC" << 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": "", "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'.