Lab 3: Branching I
- Due No Due Date
- Points 1
- Submitting a file upload
- File Types cpp
Note: You are encouraged to work on the following with a partner.
Overview
In this lab, you'll practice some of the constructs we've learned over the past few weeks, including the newest construct: branches.
Learning outcomes
By the end of this lab, you should be more comfortable...
- using getline to read in multi-word strings from the user
- using if, else if, and else statements to conditionally execute certain code
- use test operators to create Boolean expressions
Exercises
zyLab
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.36 Painting a wall
- zyLab 3.21 Remove gray from RGB
- zyLab 3.22 Smallest number
Trivia
Complete the following on your own computer using VS Code (or whatever your favorite editor is). Upload your source code to this assignment once you've completed it.
Trivia: write a program that asks the user one of each of the following types of trivia questions (in whatever order you want):
- multiple choice
- numeric
- fill in the blank
For each question, be sure you make it clear what input you are expecting (i.e., a choice like a, b, or c, a number, or a missing word(s). After reading in the user's response into a variable of the appropriate type, if their response is correct, increment a counter variable that tracks how many correct questions the user has entered.
When all three questions have been answered, report how many the user answered corrected as well as a percentage (out of 3—don't hardcode '3', though, use a constant or a variable that is incremented with each question that is asked).
Submitting
For the zyLabs, click "Submit mode" then "Submit for grading" when you are finished so I can see that you have done the zyLab. If you were able to start the Trivia program, upload your source code (the .cpp file) here.
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 3.1: Adaptive quiz
In this programming assignment, you will create an adaptive quiz. It will start off asking a medium difficult question. If the user answers correctly, they will get a more difficult second question; if they answer incorrectly, they will get a less difficult second question. For the remaining three questions, the user will see a:
- high difficulty question if they answered the previous question correctly and it was of medium or high difficulty
- medium difficulty question if they answered the previous question correctly and it was of low difficulty OR they answered it incorrectly and it was of high difficulty
- low difficulty question if they answered the previous question incorrectly and it was of low or medium difficulty
The program should track how many low, medium, and difficulty questions the user answered correctly and then display the score at the end using this formula:
score = 0.5 x low + medium + 2 x high
You have the freedom to choose the theme of your quiz (sports trivia, math problems, Kardashians trivia, whatever) and to define what low, medium, and high difficulty means. Be creative!
Complete the following header and specifications checklist and include it at the top of your source code. Before you submit, check off each of the specifications that you satisfied (note: you need to meet them all to get pass the assignment, so don't submit if you cannot check one of them off).
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA Option 3.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 with 5 questions:
// [ ] at least one question is multiple choice
// [ ] at least one question is a fill in the blank (the user enters a word or phrase to complete a sentence)
// [ ] at least one question requires a numeric response (e.g., a year, the result of a math problem, etc.) and is treated as such by your program
// [ ] the first question is medium difficulty
// [ ] the second question has two difficulty levels: low and high
// [ ] these follow the same rules outlined below for questions 3-5
// [ ] each of the remaining three questions has three levels: low, medium, and high difficulty
// [ ] the low difficult version is displayed when the user answered the previous question
// incorrectly and it was of low or medium difficulty
// [ ] the medium difficulty version is displayed when the user answered the previous question
// incorrectly and it was of high difficulty OR the user answered correctly and it was of
// low difficulty
// [ ] the high difficult version is displayed when the user answered the previous question
// correctly and was of either medium or high difficulty
// [ ] your program tracks how many low, medium, and high difficult questions were answered correctly
// [ ] your program produces an accurate score at the end
// (0.5 x # low difficulty questions answered correctly +
// # medium difficulty questions answered correctly +
// 2.0 x # high difficulty questions answered correctly)
Here are the expected scores for several combinations of easy and difficult questions answered correctly (this is not exhaustive):
# Low difficulty questions correctly answered (max is 4) |
# Medium difficulty questions correctly answered (max is 5) |
# High difficulty questions correctly answered (max is 4) | Score (0–9) |
0 | 0 | 0 | 0 |
1 | 1 | 1 | 3 |
2 | 1 | 2 | 6 |
4 | 0 | 1 | 4 |
3 | 0 | 0 | 1.5 |
0 | 1 | 4 | 9 |
Submit your PA to the First programming assignment or Second programming assignment based on whether this is your first or second 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
|
|
||
|