Computer Language
Lecture 4

Conditional statements and conditional operation

Josue Obregon

Seoul National University of Science and Technology
Information Technology Management
Lecture slides index

April 14, 2025

Class contents

  1. Introduction to Computer Programming and Java
  2. Reading Input and Strings
  3. Variables and calculation with numbers
  4. Conditional statements
  5. Repeating functionality
  6. Methods & Debugging
  7. Lists, Arrays and Strings
  8. Midterm
  1. Introduction to Object Oriented Programming
  2. Deeper look into Object Oriented Programming
  3. Inheritance and Interfaces I
  4. Inheritance and Interfaces II
  5. Class diagrams, packages and exceptions
  6. Project Live Code Review and Evaluation
  7. Final examination

Class contents

  1. Introduction to Computer Programming and Java
  2. Reading Input and Strings
  3. Variables and calculation with numbers
  4. Conditional statements
  5. Repeating functionality
  6. Methods & Debugging
  7. Lists, Arrays and Strings
  8. Midterm
  1. Introduction to Object Oriented Programming
  2. Deeper look into Object Oriented Programming
  3. Inheritance and Interfaces I
  4. Inheritance and Interfaces II
  5. Class diagrams, packages and exceptions
  6. Project Live Code Review and Evaluation
  7. Final examination

Agenda

  • Structure of conditional statements
  • Code indentation and blocks
  • Style errors
  • else and else if statements
  • Modulo operator
  • Comparing strings
  • Logical operators
  • Execution order of conditional statements

Learning objectives

  • Become familiar with the idea of a conditional statement and know how to create a program containing optional operations through the use of conditional statements.
  • Become familiar with comparison and logical operators commonly used in conditional statements.
  • Know how to compare both numbers and strings, remembering the equals-command for strings.
  • Become familiar with the order of execution for a conditional statement, and know that the parsing of a conditional statement stops at the first condition whose statement evaluates to true.

Introduction

  • Our programs have so far been linear. In other words, the programs have executed from top to bottom without major surprises or conditional behavior.
  • However, we usually want to add conditional logic to our programs.
  • By this we mean functionality that’s in one way or another dependent on the state of the program’s variables.

Conditional statements

  • To branch the execution of a program based on user input, for example, we need to use something known as a conditional statement.
  • The simplest conditional statement looks something like this:
System.out.println("Hello, world!");
if (true) {
    System.out.println("This code is unavoidable!");
}

Output

Hello, world!
This code is unavoidable!

Structure of conditional statements

  • A conditional statement begins with the keyword if followed by parentheses.
  • An expression is placed inside the parentheses, which is evaluated when the conditional statement is reached.
  • The result of the evaluation is a boolean value.
    • No evaluation occurred in the code block below. Instead, a boolean value was explicitly used in the conditional statement.
  • The parentheses are followed by a block, which is defined inside opening { and closing } curly brackets.
  • The source code inside the block is executed if the expression inside the parentheses evaluates to true.
System.out.println("Hello, world!");
if (true) {
    System.out.println("This code is unavoidable!");
}

Example: Number comparison

  • Let’s look at an example where we compare numbers in the conditional statement.
int number = 11;
if (number > 10) {
    System.out.println("The number was greater than 10");
}
  • If the expression in the conditional statement evaluates to true, the execution of the program progresses to the block defined by the conditional statement.
  • In the example above, the conditional is “if the number in the variable is greater than 10”.
  • On the other hand, if the expression evaluates to false, the execution moves on to the statement after the closing curly bracket of the current conditional statement.

Note

An if -statement is not followed by a semicolon since the statement doesn’t end after the conditional.

Integrated development environment

  • An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently.
  • It increases developer productivity by combining capabilities:
    • software editing (syntax highlighting, code editing, code completion, etc.)
    • compilation, building, testing, and packaging
    • debugging
  • So far we have been using the minimalist development environment.
  • Let’s increse our productivity by using an IDE

IDE for Java

  • Popular Java IDEs are: IntelliJ IDEA, NetBeans, Eclipse and VSCode
  • We are going to use NetBeans in our class
  • Apache NetBeans Homepage

Exercise 1 - Speeding Ticket

  • Write a program that asks the user for an integer and prints the string “Speeding ticket!” if the input is greater than 120.

Sample Output 1

Give speed:
  (user input) 15

Sample Output 2

Give speed:
  (user input) 135
Speeding ticket!

Code indentation and blocks

  • A code block refers to a section enclosed by a pair of curly brackets.
  • The source file containing the program includes the string public class, which is followed by the name of the program and the opening curly bracket of the block.
  • The block ends in a closing curly bracket.
  • In the picture below, the program block is highlighted.

Starting point of all programs

  • The recurring snippet public static void main(String[] args) in the programs begins a block, and the source code within it is executed when the program is run – this snippet is, in fact, the starting point of all programs.
  • We actually have two blocks in the example above, as can be seen from the image below.

Blocks are important

  • Blocks define a program’s structure and its bounds.
  • A curly bracket must always have a matching pair: any code that’s missing a closing (or opening) curly bracket is erroneous.
  • A conditional statement also marks the start of a new code block.
  • In addition to the defining program structure and functionality, block statements also have an effect on the readability of a program.
  • Code living inside a block is indented.
  • For example, any source code inside the block of a conditional statement is indented four spaces deeper than the if command that started the conditional statement.
  • Four spaces can also be added by pressing the tab key (the key to the left of ‘q’).
  • When the block ends, i.e., when we encounter a } character, the indentation also ends.
  • The } character is at the same level of indentation as the if-command that started the conditional statement.

Indentation examples

  • The example below is incorrectly indented.
if (number > 10) {
number = 9;
}

The example below is correctly indented.

if (number > 10) {
    number = 9;
}

Automatic code identation

  • Code in Java is indented either by four spaces or a single tab for each block. Use either spaces or tabs for indentation, not both.
  • The indentation might break in some cases if you use both at the same time.

Style errors in the submission tool

  • From now on, our program code needs to be indented correctly in the exercises we write and submit.
  • If the indentation is incorrect, the drop-project tool will not accept the solution.
  • You will see indentation errors highlighted in yellow in the test results.

Exercise 2 - Check Your Indentation

  • The exercise template contains a program demonstrating the use of conditional statements. It is, however, incorrectly indented.
  • Try to run the tests before doing anything. The drop-project tool shows the indentation errors differently compared to errors in program logic.
  • When you notice how indentation errors are shown, correct them.
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
System.out.println("Give a number: ");
int first = Integer.valueOf(scan.nextLine());
System.out.println("Give another number: ");
int second = Integer.valueOf(scan.nextLine());
if (first == second) { System.out.println("Same!"); }
else if (first > second) { System.out.println("The first was larger than the second!"); }
else {
System.out.println("The second was larger than the first!");
}

    }
}

Comparison Operators

  • > greater than
  • >= greater than or equal to
  • < less than
  • <= less than or equal to
  • == equal to
  • != not equal to
int number = 55;

if (number != 0) {
    System.out.println("The number is not equal to 0");
}

if (number >= 1000) {
    System.out.println("The number is at least 1000");
}

Output

The number is not equal to 0

Exercise 3 - Orwell

  • Write a program that prompts the user for an integer and prints the string “Orwell” if the number is exactly 1984.

Sample Output 1

Give a number:
  (user input) 1983

Sample Output 2

Give a number:
  (user input) 1984
Orwell

Exercise 4 - Ancient

  • Write a program that prompts the user for a year.
  • If the user inputs a number that is smaller than 2025, then the program prints the string “Ancient history!””

Sample Output 1

Give a year:
  (user input) 2025

Sample Output 2

Give a year:
  (user input) 2020
Ancient history!

Else

  • If the expression inside the parentheses of the conditional statement evaluates to false, then the execution of the code moves to the statement following the closing curly bracket of the current conditional statement.
  • This is not always desired, and usually we want to create an alternative option for when the conditional expression evaluates to false.
  • This can be done with the help of the else command, which is used together with the if command.
int number = 4;

if (number > 5) {
    System.out.println("Your number is greater than five!");
} else {
    System.out.println("Your number is five or less!");
}

Output

Your number is five or less!

Else branch

  • If an else branch has been specified for a conditional statement, the block defined by the else branch is run in the case that the condition of the conditional statement is false.
  • The else-command is placed on the same line as the closing bracket of the block defined by the if-command.

Exercise 5 - Positivity

  • Write a program that prompts the user for an integer and informs the user whether or not it is positive (greater than zero).

Sample Output 1

Give a number:
  (user input) 5
The number is positive.

Sample Output 2

Give a number:
  (user input) -2
The number is not positive.

Exercise 6 - Adulthood

  • Write a program that prompts the user for their age and tells them whether or not they are an adult (18 years old or older).

Sample Output 1

How old are you?
  (user input) 12
You are not an adult

Sample Output 2

How old are you?
  (user input) 32
You are an adult

More conditionals: else if

  • In the case of multiple conditionals, we use the else if command.
  • The command else if is like else, but with an additional condition.
  • else if follows the if-condition, and they may be multiple.

Let’s read out the example below to our duck partner:

int number = 3;

if (number == 1) {
    System.out.println("The number is one");
} else if (number == 2) {
    System.out.println("The given number is two");
} else if (number == 3) {
    System.out.println("The number must be three!");
} else {
    System.out.println("Something else!");
}
  1. If the number is one, then print “The number is one”,
  2. else if the number is two, then print “The given number is two”,
  3. else if the number is three, then print “The number must be three!”.
  4. Otherwise, print “Something else!”

Output

The number must be three!

Exercise 7 - Larger than or equal to

  • Write a program that prompts the user for two integers and prints the larger of the two. If the numbers are the same, then the program informs us about this as well.

Sample Output 1

Give the first number:
  (user input) 5
Give the second number:
  (user input) 3
Greater number is: 5

Sample Output 2

Give the first number:
  (user input) 5
Give the second number:
  (user input) 8
Greater number is: 8

Sample Output 3

Give the first number:
  (user input) 5
Give the second number:
  (user input) 5
The numbers are equal!

Order of execution for comparisons

  • The comparisons are executed top down. When execution reaches a conditional statement whose condition is true, its block is executed and the comparison stops.
int number = 5;

if (number == 0) {
    System.out.println("The number is zero.");
} else if (number > 0) {
    System.out.println("The number is greater than zero.");
} else if (number > 2) {
    System.out.println("The number is greater than two.");
} else {
    System.out.println("The number is less than zero.");
}

Output

The number is greater than zero.
  • The example above only prints the string “The number is greater than zero.” even though the condition number > 2 is also true.
  • The comparison stops at the first condition that evaluates to true.

Exercise 8 - Grades and points

  • The table beside describes how the grade for a particular course is determined.
  • Write a program that gives a course grade according to the provided table.
points grade
< 0 impossible!
0-49 failed
50-59 1
60-69 2
70-79 3
80-89 4
90-100 5
> 100 incredible!

Sample Output 1

Give points [0-100]:
  (user input) 37
Grade: failed

Sample Output 2

Give points [0-100]:
  (user input) 76
Grade: 3
points grade
< 0 impossible!
0-49 failed
50-59 1
60-69 2
70-79 3
80-89 4
90-100 5
> 100 incredible!

Sample Output 3

Give points [0-100]:
  (user input) 95
Grade: 5

Sample Output 4

Give points [0-100]:
  (user input) -3
Grade: impossible!
points grade
< 0 impossible!
0-49 failed
50-59 1
60-69 2
70-79 3
80-89 4
90-100 5
> 100 incredible!

Conditional statement expressions

  • The value that goes between the parentheses of the conditional statement should be of type boolean after the evaluation. boolean type variables are either true or false.
boolean isItTrue = true;
System.out.println("The value of the boolean variable is " + isItTrue);

Output

The value of the boolean variable is true
  • The conditional statement can also be done as follows:
boolean isItTrue = true;
if (isItTrue) {
    System.out.println("Pretty wild!");
}

Output

Pretty wild!

Storing comparison evaluations

  • Comparison operators can also be used outside of conditionals.
  • In those cases, the boolean value resulting from the comparison is stored in a boolean variable for later use.
int first = 1;
int second = 3;
boolean isGreater = first > second;
  • In the example above, the boolean variable isGreater now contains the boolean value false.
  • We can extend the previous example by adding a conditional statement to it.
int first = 1;
int second = 3;
boolean isLessThan = first < second;

if (isLessThan) {
    System.out.println("1 is less than 3!");
}

Variables’ values

  • The code in the image below has been executed to the point where the program’s variables have been created and assigned values.
  • The variable isItLessThan has true as its value.
  • Next in the execution is the comparison if (isItLessThan) – the value for the variable isItLessThan is found in its container, and the program finally prints:
1 is less than 3!

Remainder operator (modulo)

  • The modulo operator is a slightly less-used operator, which is, however, very handy when we want to check the divisibility of a number, for example.
  • The symbol for the modulo operator is %.
int remainder = 7 % 2;
System.out.println(remainder); // prints 1
System.out.println(5 % 3); // prints 2
System.out.println(7 % 4); // prints 3
System.out.println(8 % 4); // prints 0
System.out.println(1 % 2); // prints 1

Using modulo operator

  • If we want to know whether the number given by the user is divisible by four hundred, we check if the remainder is zero after taking the modulo of the number and four hundred.
Scanner reader = new Scanner(System.in);

int number = Integer.valueOf(reader.nextLine());
int remainder = number % 400;

if (remainder == 0) {
    System.out.println("The number " + number + " is divisible by four hundred.");
} else {
    System.out.println("The number " + number + " is not divisible by four hundred.");
}

% in conditional statements

  • Since the modulo is an operation just like other calculations, it can be a part of an expression in a conditional statement.
Scanner reader = new Scanner(System.in);

int number = Integer.valueOf(reader.nextLine());

if (number % 400 == 0) {
    System.out.println("The number " + number + " is divisible by four hundred.");
} else {
    System.out.println("The number " + number + " is not divisible by four hundred.");
}

Exercise 9 - Odd or even

  • Write a program that prompts the user for a number and informs us whether it is even or odd.

Sample Output 1

Give a number:
  (user input) 2
Number 2 is even.

Sample Output 2

Give a number:
  (user input) 7
Number 7 is odd.
  • The remainder when dividing by 2 tells us whether the number is even or not.
  • We get the remainder using the % operator.
  • Try the following commands to see what they print
System.out.println( 1%2 );
System.out.println( 2%2 );
System.out.println( 3%2 );
System.out.println( 4%2 );
System.out.println( 5%2 );
int ocho = 8
System.out.println( ocho%2 );
  • Thus, by taking the modulo of a number and two you can find out if it is even or odd!

Conditional statements with Strings

  • Even though we can compare integers, floating point numbers, and boolean values using two equals signs (variable1 == variable2), we cannot compare the equality of strings using two equals signs.
  • You can try this with the following program:
Scanner reader = new Scanner(System.in);

System.out.println("Enter the first string");
String first = reader.nextLine();
System.out.println("Enter the second string");
String second = reader.nextLine();

if (first == second) {
    System.out.println("The strings were the same!");
} else {
    System.out.println("The strings were different!");
}

Sample output 1

Enter the first string
  (user input) same
Enter the second string
  (user input) same
The strings were different!

Sample output 2

Enter the first string
  (user input) same
Enter the second string
  (user input) different
The strings were different!

Why we cant’ use == operator?

  • This has to do with the internal workings of strings as well as how variable comparison is implemented in Java.
  • In practice, the comparison is affected by how much information a variable can hold – strings can hold a limitless amount of characters, whereas integers, floating-point numbers, and boolean values always contain a single number or value only.
  • Variables that always contain only one number or value can be compared using an equals sign, whereas this doesn’t work for variables containing more information.
  • We will return to this topic later in this course.

Comparing strings

  • When comparing strings we use the equals command, which is related to string variables.
  • The command works in the following way:
Scanner scanner = new Scanner(System.in);

System.out.println("Type your secret code:");
String code = scanner.nextLine();

if (code.equals("open sesame")) {
    System.out.println("You've discovered the hidden treasure!");
} else {
    System.out.println("Sorry, that's not the magic phrase.");
}

Sample code 1

Type your secret code:
  (user input) open sesame
You've discovered the hidden treasure!

Sample code 2

Type your secret code:
  (user input) expecto patronum!
Sorry, that's not the magic phrase.

equals command

  • The equals command is written after a string by attaching it to the string to be compared with a dot.
  • The command is given a parameter, which is the string that the variable will be compared against.
  • If the string variable is being directly compared with a string, then the string can be placed inside the parentheses of the equals-command within quotation marks.
  • Otherwise, the name of the string variable that holds the string to be compared is placed inside the parentheses.
String first = reader.nextLine();
if (first.equals("Option 1")) {
  // do something
}

Another example of equals

  • In the example below the user is prompted for two strings.
  • We first check to see if the provided strings are the same, after which we’ll check if the value of either one of the two strings is “two strings”.
Scanner reader = new Scanner(System.in);

System.out.println("Input two strings");
String first = reader.nextLine();
String second = reader.nextLine();

if (first.equals(second)) {
    System.out.println("The strings were the same!");
} else {
    System.out.println("The strings were different!");
}

if (first.equals("two strings")) {
    System.out.println("Clever!");
}

if (second.equals("two strings")) {
    System.out.println("Sneaky!");
}

Sample otuput 1

Input two strings
(user input) hello
(user input) world
The strings were different!

Sample otuput 2

Input two strings
(user input) two strings
(user input) world
The strings were different!

Sample otuput 3

Input two strings
(user input) same
(user input) same
The strings were different!

Exercise 10 - Password

  • Write a program that prompts the user for a password. If the password is “Caput Draconis” the program prints “Welcome!”. Otherwise, the program prints “Off with you!”

Sample Output 1

Password?
  (user input) Wattlebird
Off with you!

Sample Output 2

Password?
  (user input) Caput Draconis
Welcome!

Exercise 11 - Same

  • Write a program that prompts the user for two strings. If the strings are the same, then the program prints “Same”. Otherwise, it prints “Different”.

Sample Output 1

Enter the first string:
  (user input) hello
Enter the second string:
  (user input) hello
Same

Sample Output 2

Enter the first string:
  (user input) hello
Enter the second string:
  (user input) world
Different

Logical operators

  • The expression of a conditional statement may consist of multiple parts, in which the logical operators and &&, or ||, and not ! are used.
    • An expression consisting of two expressions combined using the and-operator is true, if and only if both of the combined expressions evaluate to true.
    • An expression consisting of two expressions combined using the or-operator is true if either one, or both, of the combined expressions evaluate to true.
    • Logical operators are not used for changing the boolean value from true to false, or false to true.
  • In the next example we combine two individual conditions using &&, i.e., the and-operator.
  • The code is used to check if the number in the variable is greater than or equal to 5 and less than or equal to 10.
  • In other words, whether it’s within the range of 5-10:
System.out.println("Is the number within the range 5-10: ");
int number = 7;

if (number >= 5 && number <= 10) {
    System.out.println("It is! :)");
} else {
    System.out.println("It is not :(")
}

Output

Is the number within the range 5-10:
It is! :)

Example of or operator ||

  • In the next one we provide two conditions using ||, i.e., the or-operator: is the number less than zero or greater than 100.
  • The condition is fulfilled if the number fulfills either one of the two conditions:
System.out.println("Is the number less than 0 or greater than 100");
int number = 145;

if (number < 0 || number > 100) {
    System.out.println("It is! :)");
} else {
    System.out.println("It is not :(")
}

Output

Is the number less than 0 or greater than 100
It is! :)

Example of not operator !

  • In this example we flip the result of the expression number > 4 using !, i.e., the not-operator.
  • The not-operator is written in such a way that the expression to be flipped is wrapped in parentheses, and the not-operator is placed before the parentheses.
int number = 7;

if (!(number > 4)) {
    System.out.println("The number is not greater than 4.");
} else {
    System.out.println("The number is greater than 4.")
}

Output

The number is greater than 4.

Example logical expressions

Below is a table showing the operation of expressions containing logical operators.

number number > 0 number < 10 number > 0 && number < 10 !(number > 0 && number < 10) number > 0 || number < 10
-1 false true false true true
0 false true false true true
1 true true true false true
9 true true true false true
10 true false false true true

Exercise 12 - Checking the age

  • Write a program that prompts the user to input their age and checks whether or not it is possible (at least 0 and at most 120).
  • Only use a single if-command in your program.

Sample output 1

How old are you?
  (user input) 10
OK

Sample output 2

How old are you?
  (user input) 55
OK

Sample output 3

How old are you?
  (user input) -3
Impossible!

Sample output 4

How old are you?
  (user input) 150
Impossible!

Execution order of conditional statements

  • Let’s familiarize ourselves with the execution order of conditional statements through a classic programming exercise.

    ‘Write a program that prompts the user for a number between one and one hundred, and prints that number. If the number is divisible by three, then print “Fizz” instead of the number. If the number is divisible by five, then print “Buzz” instead of the number. If the number is divisible by both three and five, then print “FizzBuzz” instead of the number.’_

  • The programmer begins solving the exercise by reading the exercise description and by writing code according to the description.

  • The conditions for execution are presented in a given order by the description, and the initial structure for the program is formed based on that order.

  • The structure is formed based on the following steps:

    1. Write a program that prompts the user for a number and prints that number.
    2. If the number is divisible by three, then print “Fizz” instead of the number.
    3. If the number is divisible by five, then print “Buzz” instead of the number.
    4. If the number is divisible by both three and five, then print “FizzBuzz” instead of the number.

Implementing the solution

  • if type conditions are easy to implement using if - else if - else -conditional statements.
  • The code below was written based on the steps above, but it does not work correctly, which we can see from the example.
  • Is this solution correct?

Proposed solution

Scanner reader = new Scanner(System.in);

int number = Integer.valueOf(reader.nextLine());

if (number % 3 == 0) {
    System.out.println("Fizz");
} else if (number % 5 == 0) {
    System.out.println("Buzz");
} else if (number % 3 == 0 && number % 5 == 0) {
    System.out.println("FizzBuzz");
} else {
    System.out.println(number);
}

Sample output 1

(user input) 3
Fizz

Sample output 2

(user input) 4
4

Sample output 3

(user input) 5
Buzz

Sample output 4

(user input) 15
Fizz

What is the problem?

  • The problem with the previous approach is that the parsing of conditional statements stops at the first condition that is true. E.g., with the value 15 the string “Fizz” is printed, since the number is divisible by three (15 % 3 == 0).
  • One approach for developing this train of thought would be to first find the most demanding/restricting condition, and implement it.
  • After that, we would implement the other conditions.
  • In the previous example, the condition “if the number is divisible by both three and five” requires two things to happen.
  • Now the train of thought would be:
    1. Write a program that reads input from the user.
    2. If the number is divisible by both three and five, then print “FizzBuzz” instead of the number.
    3. If the number is divisible by three, then print “Fizz” instead of the number.
    4. If the number is divisible by five, then print “Buzz” instead of the number.
    5. Otherwise the program prints the number given by the user.

Proposed solution

Scanner reader = new Scanner(System.in);

int number = Integer.valueOf(reader.nextLine());

if (number % 3 == 0 && number % 5 == 0) {
    System.out.println("FizzBuzz");
} else if (number % 3 == 0) {
    System.out.println("Fizz");
} else if (number % 5 == 0) {
    System.out.println("Buzz");
} else {
    System.out.println(number);
}

Sample output 1

(user input) 2
2

Sample output 2

(user input) 5
Buzz

Sample output 3

(user input) 30
FizzBuzz

Sample output 4

(user input) 5
Buzz

Exercise 13 - Leap Year

  • A year is a leap year if it is divisible by 4.
  • However, if the year is divisible by 100, then it is a leap year only when it is also divisible by 400.
  • Write a program that reads a year from the user, and checks whether or not it is a leap year.

Sample output 1

Give a year:
  (user input) 2011
The year is not a leap year.

Sample output 2

Give a year:
  (user input) 2012
The year is a leap year.

Sample output 3

Give a year:
  (user input) 1800
The year is not a leap year.

Sample output 4

Give a year:
  (user input) 2000
The year is a leap year.
  • The divisibility by a particular number can be checked using the modulo operator, aka %, in the following way.
int number = 5;

if (number % 5 == 0) {
    System.out.println("The number is divisible by five!");
}

if (number % 6 != 0) {
    System.out.println("The number is not divisible by six!")
}

Output

The number is divisible by five!
The number is not divisible by six!
  • Think of the problem as a chain of if, else if, else if, … comparisons, and start building the program from a situation in which you can be certain that the year is not a leap year.
Scanner reader = new Scanner(System.in);
int number = Integer.valueOf(reader.nextLine());

if (number % 4 != 0) {
    System.out.println("The year is not a leap year.");
} else if (...) {
    ...
} ...

Checking our learning objectives

  • Become familiar with the idea of a conditional statement and know how to create a program containing optional operations through the use of conditional statements.
  • Become familiar with comparison and logical operators commonly used in conditional statements.
  • Know how to compare both numbers and strings, remembering the equals-command for strings.
  • Become familiar with the order of execution for a conditional statement, and know that the parsing of a conditional statement stops at the first condition whose statement evaluates to true.

Next week

  • Repeating functionality

Acknowledgements


Back to title slide Back to lecture slides index