You are on page 1of 12

In English,

If the number of hours is less than 41, then the pay equals hours * rate, otherwise, the pay equals 40 * rate + overtime hours * rate*1.5

In English, and in C#
If if

In English, and in C#
If the number of hours is less than 41, if (hours<41)

In English, and in C#
If the number of hours is less than 41, then pay equals hours * rate if (hours<41) pay=hours*rate;

In English, and in C#
If the number of hours is less than 41, then pay equals hours * rate, otherwise, if (hours<41) pay=hours*rate; else

In English, and in C#
If the number of hours is less than 41, then pay equals hours * rate, otherwise, the pay equals 40 * rate + overtime hours * rate*1.5 if (hours<41) pay=hours*rate; else pay = 40*rate + overtime*rate*1.5;

IF THEN ELSE, in C#
if (hours<41) pay=hours*rate; else pay = 40*rate + overtime*rate*1.5; hours<41 is a Boolean expression A Boolean expression evaluates to either true or false. If it is true, then run the statement after it , else, run the statement after else

Loops

We need to repeat steps!

Loops

We need to repeat steps:

How many repetitions? Who decides the number of repetitions? User or Programmer?

The while statement

while (Boolean Expression)

Statement

The while statement


while (Boolean Expression)
Statement

OR
while (Boolean Expression)
{Statements}

The for statement

for (Initialization; Condition Expression ; Update)

Statement

Initialization: Executed before the loop.

count=0

Condition Expression: Evaluated before each repetition.

count<Max

Update: Executed after each repetition.

count++

You might also like