CS计算机代考程序代写 compiler Java INFS1609 Fundamentals of Business Programming 2021T1 Lecture 1

INFS1609 Fundamentals of Business Programming 2021T1 Lecture 1

INFS1609 Fundamentals of Business Programming
2021T1

Lecture 2

User Input and Selections

wilbert. .au

mailto:wilbert. .au

PASS Class

Peer Assisted Study Sessions (PASS) will run from Week 02 to Week 10

Thursdays 3-4pm

Collaborate Ultra (Online)

PASS Leader: Nguyen (Khang) Bui

khang. .edu.au

INFS1609 Fundamentals of Business Programming 2

mailto:khang. .edu.au

Topics for this week

• Casting the value of one type to another type

• boolean variables and relational operators

• The if-else statement

• The switch statement

• Working with String

INFS1609 Fundamentals of Business Programming 3

Main references
• Textbook: Chapter 3 and 4
• Other online references posted on Ed

Numeric Type Conversion

Primitive data types

• A type predefined by Java and is named by a reserved
keyword

• We have eight primitive data types: ________

INFS1609 Fundamentals of Business Programming 4

Numeric Type Conversion

Primitive data types

• A type predefined by Java and is named by a reserved
keyword

• We have eight primitive data types: ________
• byte, short, int, long, float, double, boolean, char

INFS1609 Fundamentals of Business Programming 5

range increases

byte, short, int, long, float, double

Numeric Type Conversion

Implicit casting

double d = 3; (type widening)

Explicit casting

int i = (int) 3.0; (type narrowing)

int i = (int) 3.9; (fractional part is truncated)

INFS1609 Fundamentals of Business Programming 6

Numeric Type Conversion

“Automatic” implicit casting

officially called as the Assignment Conversion

• Assign a value to a numeric variable whose type supports a
larger range of values (widening a type)

• E.g., you can assign a long to a float variable

INFS1609 Fundamentals of Business Programming 7

range increases

byte, short, int, long, float, double

Numeric Type Conversion

Explicit type casting

• Narrowing a type – casting a type with a large range to a type
with a smaller range

• Syntax: specify the target type in parentheses ( ), followed by
the variable’s name

• For example: (int) 1.7

INFS1609 Fundamentals of Business Programming 8

range increases

byte, short, int, long, float, double

Numeric Type Conversion

Conversion rules

1. If one of the operands is double, the other is converted into double

2. Otherwise, if one of the operands is float, the other is converted into
float

3. Otherwise, if one of the operands is long, the other is converted into
long

4. Otherwise, both operands are converted into int

INFS1609 Fundamentals of Business Programming 9

range increases

byte, short, int, long, float, double

Numeric Type Conversion

What are the outputs?

System.out.println((double) 1 / 2);

System.out.println(1 / 2);

INFS1609 Fundamentals of Business Programming 10

Numeric Type Conversion

What are the outputs?

System.out.println((double) 1 / 2);

System.out.println(1 / 2);

The first statement displays 0.5 because 1 is cast to 1.0, then
divided by 2

INFS1609 Fundamentals of Business Programming 11

Numeric Type Conversion

Note:

Casting does not change the variable being cast

For example, the variable d is not changed after casting in the
following code:

double d = 4.5;

int i = (int) d; //i = 4 but d is still 4.5

INFS1609 Fundamentals of Business Programming 12

Numeric Type Conversion

Let’s see how we can make use of casting to perform some
useful tasks:

Write a program that displays the sales tax with two digits after
the decimal point.

INFS1609 Fundamentals of Business Programming 13

Good Programming Practices

… to help you avoid errors

Identifiers

• Names given to identify an element (e.g. class, method, variable)

• Descriptive identifiers make programs easy to read (avoid abbreviations)

• Some rules for Java:

• An identifier must start with a letter, an underscore (_), or a dollar sign
($). It cannot start with a digit.

• An identifier cannot be a reserved word (what are some reserved
words you have learned today?)

• Java is case sensitive: area, Area and AREA are all different
identifiers

INFS1609 Fundamentals of Business Programming 15

Identifier Naming Conventions

Variables and method names:

• Use lowercase. If the name consists of several words, concatenate all in
one, use lowercase for the first word, and capitalize the first letter of each
subsequent word in the name

• For example, the variables radius and area, and the method
computeArea

Class names:

• Capitalize the first letter of each word in the name

• For example, the class name ComputeExpression

INFS1609 Fundamentals of Business Programming 16

Identifier Naming Conventions

Constants:

• Capitalize all letters in constants, and use underscores to connect words

• For example, the constant PI and MAX_VALUE

INFS1609 Fundamentals of Business Programming 17

About Programming Errors

What happens if:

• You try to assign a value to a variable before declaration?

• You try to use the Scanner without import?

• You try to assign a value of a different type to a variable?

INFS1609 Fundamentals of Business Programming 18

About Programming Errors

Syntax Errors
• Detected by the compiler

Runtime Errors
• Causes the program to abort

Logic Errors
• Produces an incorrect result

INFS1609 Fundamentals of Business Programming 19

Syntax Errors

public class DemoSyntaxError {

public static main(String[] args) {

System.out.println(“Welcome to Java);

}

}

INFS1609 Fundamentals of Business Programming 20

Runtime Errors

public class DemoRuntimeError {

public static void main(String[] args) {

System.out.println(1 / 0);

}

}

INFS1609 Fundamentals of Business Programming 21

Logic Errors

public class ShowLogicErrors {

public static void main(String[] args) {

System.out.println(“Celsius 35 is Fahrenheit degree “);

System.out.println((9 / 5) * 35 + 32);

}

}

INFS1609 Fundamentals of Business Programming 22

Looking back: HourlyPay

Remember the HourlyPay example?

• If you assigned a negative value for hoursWorked in the
HourlyPay.java, the program would print an invalid result.

• If the hoursWorked is negative, you don’t want the program to
compute the gross pay. How can you deal with this situation?

INFS1609 Fundamentals of Business Programming 23

The boolean type and relational
operators

• Often in a program you need to compare two values, such as
whether i is greater than j

• Java provides six comparison operators (also known as
relational operators) that can be used to compare two values

• The result of the comparison is a boolean value: true or
false

boolean b = (1 > 2);

INFS1609 Fundamentals of Business Programming 24

The boolean type and relational
operators

Java

Operator

Mathematical

Symbol

Name Example

(radius = 5)

Result

< < less than radius < 0 false <= ≤ less than or equal to radius <= 0 false > > greater than radius > 0 true

>= ≥ greater than or equal to radius >= 0 true

== = equal to radius == 0 false

!= ≠ not equal to radius != 0 true

INFS1609 Fundamentals of Business Programming 25

The boolean type and relational
operators

public static void main (String[] args){

System.out.println(“10 > 9 is ” + (10 > 9));

}

INFS1609 Fundamentals of Business Programming 26

The boolean type and relational
operators

Operator Name Description

! not logical negation

&& and logical conjunction

|| or logical disjunction

^ exclusive or logical exclusion

INFS1609 Fundamentals of Business Programming 27

The boolean type and relational
operators

p1 p2 p1 ^ p2 Example (assume age = 24, weight = 140)

false false false

false true true (age > 34) ^ (weight >= 140) is true,

because (age > 34) is false but (weight >= 140) is true.

true false true (age > 14) ^ (weight > 140) is true,

because (age > 14) is true and (weight > 140) is false.

true true false

INFS1609 Fundamentals of Business Programming 28

The if conditional statement

INFS1609 Fundamentals of Business Programming 29

• Selectively execute part of a program

• Syntax:

if(condition) statement;

• condition is a boolean expression. If the condition is true,
then the statement is executed

One-way if statement

if i > 0 {

System.out.println(“i is positive”);

}

INFS1609 Fundamentals of Business Programming 30

(a) Wrong

(b) Correct

if (i > 0) {

System.out.println(“i is positive”);

}

One-way if statement
if (radius >= 0) {

area = radius * radius * PI;

System.out.println(“The area”

+ ” for the circle of radius ”

+ radius + ” is ” + area);

}

INFS1609 Fundamentals of Business Programming 31

The if conditional statement

INFS1609 Fundamentals of Business Programming 32

What is the output?

if(10<9) System.out.println("print me please?"); How about this? if(10<9) System.out.println("print me please?"); System.out.println("Print me?"); A simple if demo INFS1609 Fundamentals of Business Programming 33 Write a program that prompts the user to enter an integer. If the number is a multiple of 5, print HiFive. If the number is divisible by 2, print HiEven. The two-way if-else conditional statement INFS1609 Fundamentals of Business Programming 34 The two-way if-else conditional statement INFS1609 Fundamentals of Business Programming 35 if (boolean-expression) { statement(s)-for-the-true-case; } else { statement(s)-for-the-false-case; } The two-way if-else conditional statement INFS1609 Fundamentals of Business Programming 36 if (radius >= 0) {

area = radius * radius * 3.14159;

System.out.println(“The area for the ”

+ “circle of radius ” + radius +

” is ” + area);

}

else {

System.out.println(“Negative input”);

}

if-else statement with multiple
alternatives

INFS1609 Fundamentals of Business Programming 37

if (score >= 90.0)
System.out.print(“A”);

else

if (score >= 80.0)

System.out.print(“B”);

else

if (score >= 70.0)

System.out.print(“C”);

else

if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

(a)

Equivalent

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

(b)

This is better

Tracing the two-way if-else conditional
statement

INFS1609 Fundamentals of Business Programming 38

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

Suppose score is 70.0 The condition is false

Tracing the two-way if-else conditional
statement

INFS1609 Fundamentals of Business Programming 39

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

Suppose score is 70.0 The condition is false

Tracing the two-way if-else conditional
statement

INFS1609 Fundamentals of Business Programming 40

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

Suppose score is 70.0 The condition is true

Tracing the two-way if-else conditional
statement

INFS1609 Fundamentals of Business Programming 41

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

Suppose score is 70.0 Grade is C

Tracing the two-way if-else conditional
statement

INFS1609 Fundamentals of Business Programming 42

if (score >= 90.0)

System.out.print(“A”);

else if (score >= 80.0)

System.out.print(“B”);

else if (score >= 70.0)

System.out.print(“C”);

else if (score >= 60.0)

System.out.print(“D”);

else

System.out.print(“F”);

Suppose score is 70.0 Exit the if statement

Important Note

INFS1609 Fundamentals of Business Programming 43

The else clause matches the most recent if clause in the same block

Important Note

INFS1609 Fundamentals of Business Programming 44

So where you put the braces matters…

To force the else clause to match the first if clause, you must add a pair of
braces.

int i = 1;

int j = 2;

int k = 3;

if (i > j) {

if (i > k)

System.out.println(“A”);

} else

System.out.println(“B”);

Important Note #2

Adding a

semicolon to the

end of an if

condition is a

common mistake

if (radius >= 0);

{

area = radius * radius * PI;

System.out.println(

“The area for the circle of radius ”

+ radius + ” is ” + area);

}

INFS1609 Fundamentals of Business Programming 45

Wrong

Important Note #2

This mistake is

hard to find,

because it is not a

compilation error

or a runtime error,

it is a logic error.

This error often

occurs when you

use the next-line

block style.

if (radius >= 0);

{

area = radius * radius * PI;

System.out.println(

“The area for the circle of radius ”

+ radius + ” is ” + area);

}

INFS1609 Fundamentals of Business Programming 46

Wrong

Some Tips!

boolean even = number % 2 == 0;

if (even)

System.out.println(

“It is even.”);

INFS1609 Fundamentals of Business Programming 47

if (number % 2 == 0)

even = true;

else

even = false;

if (even == true)

System.out.println(

“It is even.”);

Equivalent

Equivalent

The conditional operator

x ? y : z

• It takes three arguments that together form a conditional
expression

result = grade > 70 ? “Passed” : “Failed”;

• The first argument is a boolean

• The second argument is the value of the operation if the
condition is true

• The third argument is the value of the operation if the condition
is false

INFS1609 Fundamentals of Business Programming 48

The conditional operator

x ? y : z

• It takes three arguments that together form a conditional
expression

result = grade > 70 ? “Passed” : “Failed”;

• This is equivalent to:

if (grade > 70)

result = “Passed”;

else

result = “Failed”;

INFS1609 Fundamentals of Business Programming 49

Practice: The conditional operator

Rewrite the following code using if-else statements:

tax = (income > 1000) ? income * 0.2 : income

* 0.17;

INFS1609 Fundamentals of Business Programming 50

Worked Example: Body Mass Index

Write a program that computes and interprets BMI. BMI can be
calculated by taking your weight in kilograms and dividing by the
square of your height in meters. The interpretation of BMI for
people 16 years or older is as follows:

INFS1609 Fundamentals of Business Programming 51

BMI Interpretation

BMI < 18.5 Underweight 18.5 <= BMI < 25.0 Normal 25.0 <= BMI < 30.0 Overweight 30.0 <= BMI Obese Example: Testing the logical operators INFS1609 Fundamentals of Business Programming 52 Ed > Lessons > Week 02 Code Examples > TestLogicalOperators

Questions?

… before the switch statement

The switch statement

When to use the switch statement?

• A sequence of comparisons needs to be made against
several constant alternatives

A switch statement evaluates an expression to determine a
value and then matches that value with one of several possible
cases

INFS1609 Fundamentals of Business Programming 54

The switch statement

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 55

The switch statement flowchart

INFS1609 Fundamentals of Business Programming 56

The switch statement

The switch-

expression must

yield a value of

char, byte, short,

or int type and must

always be enclosed

in parentheses

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 57

The switch statement

How about the
String type?

https://docs.oracle.com/javase/tutorial/

java/nutsandbolts/switch.html

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 58

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

The switch statement

value1, …, and

valueN must have

the same data type

as the value of the
switch-

expression.

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 59

The switch statement

The resulting

statements in the

case statement are

executed when the

value in the case

statement matches

the value of the
switch-

expression

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 60

The switch statement

Note that value1,

…, and valueN are

constant

expressions,

meaning that they

cannot contain

variables in the

expression, such as
1 + x

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 61

The switch statement

The keyword break

is optional, but it

should be used at the

end of each case in

order to terminate the

remainder of the

switch statement. If
the break statement

is not present, the

next case statement

will be executed

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

INFS1609 Fundamentals of Business Programming 62

The switch statement

When the value in a
case statement

matches the value of
the switch-

expression, the

statements starting from

this case are executed
until either a break

statement or the end of
the switch statement

is reached.

INFS1609 Fundamentals of Business Programming 63

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

The switch statement

The default case,

which is optional, can

be used to perform

actions when none of

the specified cases

matches the
switch-

expression

INFS1609 Fundamentals of Business Programming 64

switch (switch-expression) {

case value1: statement(s)1;

break;

case value2: statement(s)2;

break;

case valueN: statement(s)N;

break;

default: statement(s)-for-default;

}

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 65

Suppose day is 2

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 66

Match case 2

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 67

Fall through case 3

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 68

Fall through case 4

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 69

Fall through case 5

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 70

Encounter break

Tracing the switch statement

switch (day) {

case 1:

case 2:

case 3:

case 4:

case 5: System.out.println(“Weekday”); break;

case 0:

case 6: System.out.println(“Weekend”);

}

INFS1609 Fundamentals of Business Programming 71

Exit the statement

Practice: The switch statement

INFS1609 Fundamentals of Business Programming 72

Do some coding!

Creating the same example using String

The String type

INFS1609 Fundamentals of Business Programming 73

• String is actually a predefined class in the Java library just
like the System class and Scanner class.

• The String type is not a primitive type. It is known as a
reference type.

• Reference types will be thoroughly discussed later.

• For the time being, you just need to know how to declare a
String variable, how to assign a string to the variable, how to
concatenate strings, and how to perform simple operations for
Strings.

Simple methods for String objects

INFS1609 Fundamentals of Business Programming 74

Method Description

Returns the number of characters in this string.

Returns the character at the specified index from this string.

Returns a new string that concatenates this string with string s1.

Returns a new string with all letters in uppercase.

Returns a new string with all letters in lowercase.

Returns a new string with whitespace characters trimmed on both sides.

length()

charAt(index)

concat(s1)

toUpperCase()

toLowerCase()

trim()

Getting characters from a String

Working with the .charAt() method

String message = “Welcome to Java”;

System.out.println(“The first character in

message is ” + message.charAt(0));

INFS1609 Fundamentals of Business Programming 75

Converting Strings

“Welcome”.toLowerCase() returns a new string “welcome”

“Welcome”.toUpperCase() returns a new string “WELCOME”

” Welcome “.trim() returns a new string “Welcome”

INFS1609 Fundamentals of Business Programming 76

String concatenation

String s3 = s1.concat(s2); or String s3 = s1 + s2;

// Three strings are concatenated

String message = “Welcome ” + “to ” + “Java”;

// String Chapter is concatenated with number 2

String s = “Chapter” + 2; // s becomes Chapter2

// String Supplement is concatenated with character B

String s1 = “Supplement” + ‘B’; // s1 becomes SupplementB

INFS1609 Fundamentals of Business Programming 77

Reading Strings from the console

Scanner input = new Scanner(System.in);

System.out.print(“Enter three words separated by spaces: “);

String s1 = input.next();

String s2 = input.next();

String s3 = input.next();

System.out.println(“s1 is ” + s1);

System.out.println(“s2 is ” + s2);

System.out.println(“s3 is ” + s3);

INFS1609 Fundamentals of Business Programming 78

Reading a character from the console

INFS1609 Fundamentals of Business Programming 79

Scanner input = new Scanner(System.in);

System.out.print(“Enter a character: “);

String s = input.nextLine();

char ch = s.charAt(0);

System.out.println(“The character entered is ” + ch);

Comparing Strings

INFS1609 Fundamentals of Business Programming 80

Method Description

Returns true if this string is equal to string s1.

Returns true if this string is equal to string s1; it is case insensitive.

Returns an integer greater than 0, equal to 0, or less than 0 to indicate whether

this string is greater than, equal to, or less than s1.

Same as compareTo except that the comparison is case insensitive.

Returns true if this string starts with the specified prefix.

Returns true if this string ends with the specified suffix.

equals(s1)

equalsIgnoreCase(s1)

compareTo(s1)

compareToIgnoreCase(s1)

startsWith(prefix)

endsWith(suffix)

Obtaining substrings

INFS1609 Fundamentals of Business Programming 81

Method Description

Returns this string’s substring that begins with the character at the specified

beginIndex and extends to the end of the string, as shown in Figure 4.2.

Returns this string’s substring that begins at the specified beginIndex and

extends to the character at index endIndex – 1, as shown in Figure 9.6.

Note that the character at endIndex is not part of the substring.

substring(beginIndex)

substring(beginIndex,

endIndex)

Obtaining substrings

int k = s.indexOf(‘ ‘);

String firstName = s.substring(0, k);

String lastName = s.substring(k + 1);

INFS1609 Fundamentals of Business Programming 82

The output

Conversion between Strings and
numbers
String intString = “123”;

int intValue = Integer.parseInt(intString);

INFS1609 Fundamentals of Business Programming 83

parseInt is a method

in the Integer class

Try to perform parseInt

with a non-numerical
String! What is the

output?

One last thing!

Casting between char and numeric types

The char data type and code values

int test = 65;

System.out.println((char)test);

INFS1609 Fundamentals of Business Programming 85

Characters Code Value in Decimal Unicode Value

‘0’ to ‘9’ 48 to 57 \u0030 to \u0039

‘A’ to ‘Z’ 65 to 90 \u0041 to \u005A

‘a’ to ‘z’ 97 to 122 \u0061 to \u007A

Casting between char and numeric
types

int i = ‘a’; // Same as int i = (int)’a’;

char c = 97; // Same as char c = (char)97;

Think about what the output is and test it in your Ed Workspace!

INFS1609 Fundamentals of Business Programming 86

Numeric operators with the char type

• A char operand is automatically cast into a number if the
other operand is a number or a character

• If the other operand is a String, the character is
concatenated with the String

int i = ‘2’ + ‘3’;

System.out.println(“i is: ” + i);

//i is 101 because 2 is 50 and 3 is 51

INFS1609 Fundamentals of Business Programming 87

Numeric operators with the char type

int j = 2 + ‘a’; //(int)‘a’ is 97

System.out.println(“j is: ” + j); //j is 99

System.out.println(j + “ is the Unicode for

character ” + (char)j);

//j is the Unicode for character c

INFS1609 Fundamentals of Business Programming 88

The char data type and operations

Note: The increment and decrement operators can also be used
with the char variables

• The operators will get the next, or preceding, Unicode
character

• For example, the following statement displays the character b

char ch = ‘a’;

System.out.println(++ch);

INFS1609 Fundamentals of Business Programming 89

Next Week

1. A design strategy to develop loops
2. while, do-while and for loops

3. Similarities and differences between

the different types of loops

4. Nested loops

5. Implementing program control using
break and continue

INFS1609 Fundamentals of Business Programming

Reflection What have you learned today?

INFS1609 Fundamentals of Business Programming

Thank you!