Home
Examples
Labs
Assignments
Marks
Midterm
Final Exam
Resources

Code Examples

print a Hello message on the screen

String concatenation using the + operator
String concatenation using the concat() method
printing String literals and String variables

integer addition
float addition
evaluating expressions - simple example
math with float variables - nicer output

String methods trim() and length() - Saskatoon example
String methods toUpperCase() and toLowerCase()
String method subString()

receiving input from the keyboard

order of operations
integer division and modulus (remainder)
using Math.abs()
some more examples with Math
solving the quadratic equation

converting to letter grades - using an if else statement
converting to letter grades - using multiple if statements

while you see stars
while loop to print the numbers from 1 to 10
while loop to print the numbers from 10 down to 1
while to sum a list of numbers - Sentinal Example

for loop to print the numbers 1 to 10

for loop to print the numbers 10 down to 1

while loop for a menu program
do loop for a menu program

Using Helper Methods

while loop to get valid input
do loop to get valid input

using a loop to process along a String

Defining a Pizza class

Defining a Person class