Lab 4: Branching II
- Due No Due Date
- Points 1
Note: You are encouraged to work on the following with a partner.
Overview
In this lab, you'll practice more with branches, Boolean expressions, and string functions.
Learning outcomes
By the end of this lab, you should be more comfortable...
- using branches
- writing if/else if/else statements
- writing Boolean expressions
- using string functions like at, find, push_back, and replace
Exercises
Complete the following zyLabs in the zyBook. While you do them, be sure to implement incrementally—write a line or two of code, then compile/run it. Test frequently by clicking "Submit mode" and then "Submit for grading". You have unlimited submits, so don't worry about using some quota up.
- zyLab 2.37 Password generator
- zyLab 3.23 Interstate highway numbers
- zyLab 3.24 Seasons
- zyLab 3.30 Text message expander
Submitting
Click "Submit mode" then "Submit for grading" when you are finished so I can see that you have done the zyLab.
PA options
Please see the syllabus and course schedule (both on the homepage) for more information about how many programming assignments you are required to pass, due dates, etc. Of note: you do not need to attempt every or even most PAs.
PA 4.1: Password generator+
In this programming assignment, you will modify the password generator form zyLab 2.37 so that it works as follows:
- four character groups are coded in constants at the top of main (upper case, lower case, numbers, special characters)
- e.g., the uppercase letters would look like this: const string UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- the user should be prompted to enter a line of input specifying each of the groups they want to include, for example:
- example 1: if the user entered `uppers lowers nums specials`, it means include all the groups
- example 2: if the user entered `uppers lowers`, it means include just the alphabetical characters
- use if statements to add each group the grand character list
- you should only need four if statements for this
- also prompt the user to select the length: short (5 chars), medium (10) or long (20)
- use branches to handle each of these three cases
- you will need a lot of copying and pasting for these...
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA Option 4.1
// [ ] your header includes your name and anyone you worked with
// [ ] your header includes this specifications checklist
// [ ] your code in indented properly (use the autoformatter if you're not sure)
// [ ] your identifiers are well named
// [ ] your program compiles
// [ ] your program runs without crashing
// [ ] all output and prompts look clean (correct spelling, capitalization, nothing squished)
// [ ] your program prompts the user for a line of input that include each of the character
// groups they want to include in their password
// [ ] the valid group options are: uppers (A-Z), lowers (a-z), nums (0-9),
// specials (!@#$%^&*()-_[]'";:.,><~`\|)
// [ ] each character group is stored in its own constant string, defined at the top of main,
// using the proper conventions (the constant names are all caps)
// [ ] your program uses branches to decide whether to add each character group to the string
// of characters to generate the password from
// [ ] your program prompts the user for the size of the password: one of short (5 characters),
// medium (10 characters), or long (20 characters)
// [ ] each case is handled with a branch
// [ ] the password is generated randomly using only characters from the user-specified groups
// [ ] `srand(time(0))` is used rather than `srand(1)` or something similar
Here are the expected scores for several combinations of easy and difficult questions answered correctly (this is not exhaustive):
Submit your PA to First programming assignment, Second programming assignment, or Third programming assignment based on whether this is your first, second, or third PA. If you are working with a partner, both of you must submit individually.
Rubric
Criteria | Ratings | ||
---|---|---|---|
Worked diligently on the lab problems
|
|
||
Submitted all materials according to the instructions
|
|
||
|