TUTORIAL 05
BUSI 2402 APPLICATION DEVELOPMENT
AGENDA
• Repetition (Loops)
• Midterm Review
REPETITION
Repetition allows us to repeat a series of steps multiple
times, including:
• Moving through a list of values.
• (Re) Calculating something until a desired result is
achieved.
• Keeping an application active until the user indicates
to close it.
FOR LOOPS
FOR loops are used when you want to
for (statement 1; statement 2; statement 3)
repeat a specific number of times.
{
// code block to be executed
}
statement 1 runs once when the for loop is called.
statement 2 defines when code will run.
statement 3 runs after the code runs.
FOR LOOPS
This FOR loop cycles through a list
of values.
for (int i = 0; i < 5; i++)
{ Output:
[Link](i);
}
statement 1 creates integer i and initializes it to 0
statement 2 the for loop runs for as long as i is less than 5
statement 3 i increases by 1 every time the loop completes
The value of i is printed to the Console every time the loop runs.
DO-WHILE / WHILE-DO LOOPS
WHILE loops are used when you want
to repeat until a condition is met.
while (condition)
{
// code block to be executed
}
The condition could be any question that returns TRUE or FALSE.
DO-WHILE / WHILE-DO LOOPS
WHILE loops can be used to keep an app
active until the user indicates to close it.
String userChoice =“”;
Note for this example: Here “!
[Link](“Exit”) is used to say “not equal
while () to Exit”
{ Don’t use “==“ when comparing Strings like when
you compare numbers
[Link](“Enter ‘Exit’ to stop: “);
Strings are not primitive data types and “==“ won’t
userChoice = [Link](); compare them
}
The condition asks if the user wants to exit by entering “Exit”, if the user types “Exit”, the loop stops/exits
DO-WHILE / WHILE-DO LOOPS
This WHILE loop also cycles
through a list of values.
int i = 0;
while (i < 5) Output:
{
[Link](i);
i++;
}
The condition asks if i is less than 5 and continues until it is 5 or more.
DO-WHILE / WHILE-DO LOOPS
int j = 5; Output:
do
{
[Link](j);
j++;
}
while (j < 5);
The do-while is a variation where the loop executes at least once before the condition is checked.
BREAK / CONTINUE
• BREAK and CONTINUE are special keywords that can be used in loops to alter
behaviour.
• BREAK can be used to jump out of a loop.
• CONTINUE can be used to skip a loop iteration.
ASSIGNMENT 2 DUE NOV 3 AT 10 PM
• Use the UML solution for Assignment 1 as your reference when working on
part III: Yacht Club
ZYBOOKS DUE OCT 31ST
• Participation activities
• Chapters 1 to 6 is due on October 31st
MIDTERM REVIEW – NOV 5 TO 9
There will be a midterm exam covering material in the textbook and taught in class up to and including the
lecture before the exam.
The exam will include 2 – 30 minutes each quizzes in Brightspace.
• These are timed quizzes. Once you start them you will have only 30 minutes to complete them.
• You can decide when to take them.
It also includes a business case based on your student number about creating a Class Diagram.
• A PDF containing the student’s solution must be uploaded to Brightspace before the deadline.
MIDTERM REVIEW
Object Oriented Paradigm Programing In Java
• Classes & Objects • Data Types
• UML Class Diagrams • Declaring & Initializing Variables
• Creating Classes & Objects (Attributes,
Programing In General Constructors, Setters/Getters, Other
Behaviour)
• Attributes (Variables) & Behaviours
(Methods) • Mathematical Operators (Add, Subtract,
Multiple, Divide, Comparison)
• Branching
• Logical Operators (Boolean Logic)
• Repetition
• Declaring Functions (Return Types,
Arguments)
MIDTERM REVIEW
Types of Quiz Problems:
Interpret Code
• Here is code, (1) what is missing? or (2) what will it output?
• Math Problems, Complete Classes, etc.
Choose Code
• You need to do XYZ, which statement will achieve it?
MIDTERM REVIEW
Plan your time appropriately
• Keep in mind the time limits for each quiz.
• Keep in mind the deadlines.
To be completely individually
• Without assistance from the TA or Instructor
GOING FORWARD
• Best of luck with your midterm!