Assignment 1. Getting Your C++ Legs

Due Friday, April 9 at 11:59 pm Pacific

  • Submissions received by due date receive a small on-time bonus.
  • All students are granted a pre-approved extension or "grace period" of 48 hours after the due date. Late submissions are accepted during the grace period with no penalty.
  • The grace period expires Sun, Apr 11 at 11:59 pm Pacific, after which we cannot accept further late submissions.
  • In this course, we express all date/times in Pacific time GMT -7. Our Paperless submission system also displays/records due dates and submission times in Pacific time.

Here it is – the first programming assignment of the quarter! Completing this assignment will get you up and running with the C++ language and the tools used in CS106B. The work involves a mix of coding, testing, and debugging tasks. By the end of this assignment, you'll have fully gotten your C++ legs under you! (our apologies for the bad pun…)

The code you will write involves expressions, control structures, functions, and string processing. You have prior experience with these concepts, but the tricky part is figuring how to map what you already know to the strange new world of C++. The transition is what this assignment is all about. In addition to giving you practice with C++ syntax and libraries, the assignment will guide you through the tools and approaches you can use to test and debug your code. By the time you've completed it, you'll be a lot more comfortable working in C++ and will be ready to start building larger projects!

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

Learning goals

  • To become comfortable using the Qt Creator IDE 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.

  • Perfect Numbers

    is a fun warmup exercise involving number theory, algorithms, and optimization. It gives you a guided transition into C++, as well as the testing and debugging tools that we will be using in CS106B this quarter. You can start on this task right away – and we recommend doing so! Completing this 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. Make sure that you have watched the lectures on strings and Vectors before starting on this part. 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 (using the Ed forum, LaIR, and instructor office hours) if you hit any snags. At the end of this part of the assignment you'll also answer some reflective ethical questions regarding the name classification system that you just implemented!

Getting started

We provide a ZIP of the starter project. Download the zip, extract the files, and double-click the .pro file to open the project in Qt Creator.

📦 Starter code

The two source files you will edit are:

  • perfect.cpp
  • soundex.cpp

Additionally, you will write short answers to some questions in short_answer.txt.


  • The CS106B Style Guide reviews the coding standards in the rubric applied to grading the style of your submission.
  • The CS106B guide to testing your code explains the use of SimpleTest.
  • This guide to transitioning from Python to C++ points out syntactical and functional differences between the two languages. Thank you to section leaders Jillian Tang and Ethan Chi for this wonderful resource!

Getting Help

As always, feel free to reach out to us if you have questions. You can contact us on Ed, email your section leader, or stop by the virtual LaIR, or come to office hours. As a reminder, try to visit the LaIR for coding debugging questions – however, if you cannot make it to the LaIR due to timezone issues, you can post on Ed to get help. However, you must use a private post if you are including code so that you are not posting your solutions for the whole class to see.


Before you call it done, run through our submit checklist to be sure all your t's are crossed and i's 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

Note: On Paperless, all due dates and submission times are expressed in Pacific time.

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