- Make sure you follow along with this page linked in Canvas
- Please keep your microphone off unless you are asking a question
- Please turn on camera if you can (optional)
- Use chat if you would like to comment or ask questions

See Announcements link in Canvas to keep up with what is going on. Here are a few for review:

- ZyBook required for course--email me if this is a financial hardship
- Grace period--assignments due before 9/11 can complete be until 9/11 at 9:00pm
- Second Harvest Food Bank Fresh Market Drive Through 9/14 9:30-11am Watsonville Campus, Parking Lot C
- Please complete the census my2020census.gov (takes 5 minutes), by phone at 1-844-330-2020, or by mail using the form you received
- Register to vote by October 18th at: https://registertovote.ca.gov/

- Viewing Canvas assignment and exercise results
- Computer Technology Center: Technical support
- Tutoring resources: also NetTutor in Canvas

- Must attend the class meeting to take these quizzes
- Quizzes assess the reading and participation activities due before the class meeting

- Complete this quiz solo to assess your reading comprehension and readiness for the class
- Quiz is open book and notes but timed
- Login to Canvas

- Will move to breakout rooms with your team
- Openly discuss what you believe to be the best answers for the questions
- Decide how to agree on the answers
- Strive to reach a consensus on quiz answers
- If no consensus, work it out as you and others in your group see fit

- Turn in the quiz as a group
- Each group member will receive the same score

- After completing the group quiz, group members may appeal an answer
- Appeals can be based on two criteria:
- Question is
**factually wrong**Appeal must included citations to sources of information that document or support an alternative answer. Team may access reference materials during the appeal.

- Question is
**confusing based on it's wording**Appeal must include an appropriate rewrite of questions or answers that you interpret as ambiguous or confusing.

- Question is
- Work with teammates to develop and write any appeals
- Team has up to 24 hours after the quiz to email appeal to instructor
- If appeal is granted, only the teams that submitted appeal gets credit

Any problems with any of these Coding Challenges? Zybooks sign in

If so, list the numbers in Chat

- 2.2.1 Enter the output of the variable assignments. (Progression)
- 2.2.2 Assigning a sum. (Coding challenge)
- 2.2.3 Declaring and initializing variables. (Coding challenge)
- 2.2.4 Adding a number to a variable. (Coding challenge)

Understanding variables and assignment is critical to being able to program but is an easy thing to be confused about. Get over this hurdle and programming will be far easier.

In this exercise we complete a series of dry run exercises where we step through short fragments of code. This is an important activity to reinforce your understanding of variables. The instructor will step through the first exercise with you.

- Start a text editor and create a file named
`variables.txt`

- Open the Variable Assignment Tracing Exercises page.
- Click the first problem and follow the steps, filling in the boxes to get the final answers.
- After completing a problem and before continuing to the next,
**compare your answers with other team members**.Discuss and resolve and discrepancies between answers.

- After verifying your answer,
**record the problem number and final values of all variables**in your`variables.txt`

file.As an example for problem 1:

1. Final value of x is 7. Final value of y is 7.

- Repeat this process for the remaining exercise problems.
- After finishing all the exercise problems, answer the
**Check Understanding**questions and record the question number and answer on your paper.As an example for question 10a:

10a. false

When finished, please help your team members and then return to the class meeting.

Any problems with any of these Coding Challenges? Zybooks sign in

If so, list the numbers in Chat

- 2.5 Arithmetic expressions (int) (Coding challenge)
- 2.5.1 Compute an expression. (Coding challenge)
- 2.5.2 Total cost. (Coding challenge)
- 2.7 Floating-point numbers (double) (Coding challenge)
- 2.7.1 Sphere volume. (Coding challenge)
- 2.8 Using math functions (Progression)
- 2.8.1 Math functions. (Progression)
- 2.8.2 Writing math calculations. (Coding challenge)
- 2.8.3 Using math functions to calculate the distance between two points (Coding challenge)
- 2.9 Integer division and modulo (Progression)
- 2.9.1 Enter the output of the integer expressions. (Coding challenge)
- 2.9.2 Compute change. (Coding challenge)
- 2.10 Type conversions (Progression)
- 2.10.1 Type conversions. (Coding challenge)
- 2.10.2 Type casting: Computing average kids per family (Coding challenge)

Through the miracles of computer science, we will now convert your $500 computer into a $5 calculator! Along the way, we learn how to work with arithmetic using C++.

For this exercise we break into teams. Within the team, work with each other to develop a solution. When the team has finished, Choose one member to show your solution to the class by sharing your screen. The instructor will ask one team to share their solution.

- Start Repl.it, update the code in the text editor, and then compile and run the starter program to make sure you typed it correctly.
#include <iostream> using namespace std; int main() { // Type your code here }

- Within the curly braces of the
`main()`

function, declare two`double`

variables named`a`

and`b`

, and assign them a value of`5`

and`2`

respectively. For instance:double a = 5, b = 2;

- Add a line of code to display the arithmetic expression
`(a + b)`

and then recompile and run the program.cout << "a + b = " << a + b << endl;

Notice that the last letter on

`endl`

is a lower-case "L", NOT a one. Verify the output of the program looks like this:a + b = 7

If you do not see this output, please type a chat message asking for help.

- Add three more lines of code like the previous one that computes the expressions:
`a - b`

,`a * b`

and`a / b`

. Compile and run your program again and make sure your program now displays the following output:a + b = 7 a - b = 3 a * b = 10 a / b = 2.5

- The order of operations matters in C++ just like it does in algebra. Multiplication and division are performed before addition and subtraction. Add the following two statements to your program:
cout << "a + b / 2 = " << a + b / 2 << endl; cout << "(a + b) / 2 = " << (a + b) / 2 << endl;

- Compile and run your program again and compare the output. Your program should now display the following output:
a + b = 7 a - b = 3 a * b = 10 a / b = 2.5 a + b / 2 = 6 (a + b) / 2 = 3.5

Note how the output of the two statements is different. You can change the order of operation using parenthesis, just like in algebra. For more information on the order of operations see section: 2.3.2: Arithmetic.

As you can see, arithmetic in C++ works much like you would expect.

- Once satisfied with your code, copy your code into a text editor, save the file as "
`arithmetic.cpp`

", and to submit the file to Canvas with the rest of the exercise files for the week.

When finished developing your code **click here** to verify. Code need not look exactly the same. After you have completed your own program, reviewing another is often helpful in learning how to improve your programming skills.

In this exercise we use integer division, modulus, and mathematical functions to create a deluxe calculator.

For this exercise we break into teams. Within the team, work with each other to develop a solution. When the team has finished, Choose one member to show your solution to the class by sharing your screen. The instructor will ask one team to share their solution.

- In Repl.it, start with your
`arithmetic.cpp`

code from the last Exercise. **Integer Division**: Modify your`arithmetic.cpp`

code from the last exercise by changing the data type of the two variables from`double`

to`int`

, like this:**int**a = 5, b = 2;- Compile and run your program again and compare the output. Note how the result of the division operation changed. What happened to the decimal part of the result?
In programming terms, we say that the decimal part is truncated (cut short). We have to watch out for this in C++ programming or we may get unexpected results in our calculations.

**Modulus (%) operator**: Sometimes we want the integer remainder from an integer division. To see the integer remainder, we use the modulus (%) operator. Add the following statements after the other`cout`

statements:cout << "a % b = " << a % b << endl; cout << "a / b % b = " << a / b % b << endl; cout << "a / (b * b) = " << a / (b * b) << endl;

- Compile and run your program again with this added statement. Your program should now display the following output:
a + b = 7 a - b = 3 a * b = 10 a / b = 2 a + b / 2 = 6 (a + b) / 2 = 3 a % b = 1 a / b % b = 0 a / (b * b) = 1

**Mathematical functions**: More complex mathematical operations require the use of a function in C++. One such function is`sqrt(`

which calculates the square root of the*number*)*number*inside the parenthesis.- Add the following statement to your program:
cout << "sqrt(a + b) = " << sqrt(a + b) << endl;

- Your program will not compile with this new statement because you must include a library of the mathematical functions. Add the statement:
`#include <cmath>`

to the top of your program like this:#include <iostream>

**#include <cmath> // math function library**using namespace std; - Compile and run your program again with this added statement. Your program should now compile and display the following output when run:
a + b = 7 a - b = 3 a * b = 10 a / b = 2 a + b / 2 = 6 (a + b) / 2 = 3 a % b = 1 a / b % b = 0 a / (b * b) = 1 sqrt(a + b) = 2.64575

- Once satisfied with your code, copy your code into a text editor, save the file as "
`calculator.cpp`

", and to submit the file to Canvas with the rest of the exercise files for the week.

When finished developing your code **click here** to verify. Code need not look exactly the same. After you have completed your own program, reviewing another is often helpful in learning how to improve your programming skills.