Getting Your C++ Legs

Wednesday, July 3


Due Wednesday, July 3 at 11:59 PM

  • Submit to Paperless. Deadline is 11:59 PM.
  • The late day policy gives you the ability to self-grant an extension (as long as you have not used all your late days); we trust you will make reasonable and sparing use of this power. Be sure to reserve late days for emergencies.
  • Reminder: You have a limited pool of late days. You have a total of 4 late days to use throughout the quarter, but you cannot use more than 2 late days per assignment. Late days are expended in 24-hour blocks. See the Assignments page for more details.

Here it is – the first programming assignment of the quarter! This assignment is a mix of coding, testing, and debugging tasks that get you practicing with the C++ language and development tools.

The code you are to write uses expressions, control structures, functions, and string processing. Your prerequisite work means you should be familiar with these concepts; the novelty comes in figuring how to take what you already know and translate into the curious new world of C++. You also will build familiarity with the development tools we use and be introduced to strategies for testing and debugging your code. By the time you've completed the assignment, you'll be more comfortable working in C++ and ready to start building larger projects, or as we like to say, you'll have gotten your C++ legs under you! (apologies for the bad pun…)

This assignment is to be completed individually. Working in pairs/groups is not permitted.

Learning goals

  • To become comfortable using Qt Creator to edit, build, run, and debug simple C++ programs.
  • To practice writing C++ functions that manipulate numbers and strings.
  • To learn basic use of the SimpleTest framework for unit tests and time trials.

Assignment parts

This assignment consists of two parts. Click on the links below for the full instructions.

  • Perfect Numbers

    is a warmup exercise involving number theory, algorithms, and optimization. It gives you a guided transition into C++ and the testing and debugging tools we use. You can start on this task right away — and we recommend doing so! Completing the warmup in the first few days reserves the better part of the week for the bigger second part.

  • is a complete program that demonstrates a nifty algorithm for matching and grouping names based on their pronunciation. This program uses C++ strings, console I/O, and the Vector class. There is a substantial chunk of code for you to write, so get an early start to give yourself sufficient time to work through issues and reach out for help if you hit any snags.

Getting started

📦 Starter project

The starter project is provided as a zip archive. Download the zip, extract the files, and move the project folder to your CS106B folder. Open the .pro file in Qt Creator to get started.

Resources

  • The CS106B guide to SimpleTest on testing your code using the SimpleTest framework.
  • A guide to C++ strings written by our awesome colleague Keith Schwarz.
  • This Python to C++ transition guide points out syntactical and functional differences between the two languages. Thank you to section leaders Jillian Tang and Ethan Chi for this wonderful resource.
  • Resolving Common Build/Run Errors, compiled by section leader Jillian Tang.
  • The CS106B Style Guide explains the rubric and standards we use when evaluating the style of your code.

Getting Help

We are here to help if you get run into issues along the way! The Ed forum is open 24/7 for general discussion about the assignment, lecture topics, the C++ language, using Qt, and more. Always start by searching first to see if your question has already been asked and answered before making a new post.

To troubleshoot a problem with your specific code, your best bet is to bring it to the LaIR helper hours or office hours.

Submit

Before you call it done, run through our submit checklist to be sure all your ts are crossed and is are dotted. Then upload your completed files to Paperless for grading.

Please submit only the files you edited; for this assignment, these files will be:

  • perfect.cpp
  • soundex.cpp
  • short_answer.txt

You don't need to submit any of the other files in the project folder.

🏁 Submit to Paperless

That's it; you're done! Congratulations on finishing your first CS106B assignment!