Lesson 2 – Algorithms and Pseudocode

Big Java 6

When you come in

  1. Connect to the Internet
  2. Log in to Piazza
  3. Start Bluej
  4. Navigate to laughton.com/obrien/sjsu/cs46a/CRT_lessons/ and open this lesson

Questions

Concepts - Algorithms

A sequence of instructions taken to solve a problem

An algorithm must be:

Concepts - Pseudocode

Activity - Reading Pseudocode

Record your participation in Piazza clicker question Lesson2 Q1

Here is pseudocode to determine if a student passed or failed

If student's grade is greater than or equal to 73
      Print "passed"
 else
      Print "failed" 

What is printed when the grade is 73, 72, 71? Mark the correct answer in Piazza Lesson2 Q1

  1. passed, passed passed
  2. failed, failed, failed
  3. passed, passed, failed
  4. passed, failed, failed

 

Activity - Designing an Algorithm in Pseudocode

Record your participation in Piazza clicker question Lesson2 Q2

Design an algorithm to build this Duplo staircase using pseudocode.

Write it on a piece of paper or in a text file

aligned left: a 2X2 duplo on top of a 2X4 on top of a 2X6 on top of a 2X8

Activity - Using Methods of the Picture class

Record your participation in Piazza clicker question Lesson2 Q3

 

Activity - Using the Day class

Record your participation in Piazza clicker question Lesson2 Q4

Copy the Day class from here

From the Day class, we can make Day objects and call their methods

Now write an application using Day objects:

Activity - Variable names

Record your participation in Piazza clicker question Lesson2 Q5

Which of the following are valid variable names and follow the Java conventions? Check all that apply.

  1. taxRate
  2. tax rate
  3. 7Up
  4. public
  5. day
  6. Removed
  7. t
  8. taxrate

 

 

Activity - Pseudocode

Record your participation in Piazza clicker question Lesson2 Q6