Objectives

Students will be able to:

  • develop flowcharts to represent a variety of loop structures.

Algorithm

An algorithm is a defined set of steps that can be followed to solve a problem.

Flowcharts

Flowchart Symbols

One strategy to allow program designers and programmer to share computational solutions is to use flowcharts.

They include a variety of symbols.

Here are some common ones. Click on each one to see its purpose.

Task 1 - Pair/Share

An can be represented by a flowchart.

(Preferably) with a partner or group, complete the Worksheet.

Task 2 - Video

Open the worksheet and complete the tasks.

Task 2

Using any of the symbols above, draw a flowchart to represent the following algorithm:

int[] nums = {2,6,4,18,5};

for(int i = 0; i<nums.length; i++){

if(nums[i]>max){

max = nums[i];

}

}

System.out.println(max);

Task 3

Here is some more Java code

String word = new String("");

do{

System.out.println("Enter a 5 letter word");

word = scan.nextLine()

}while(word.length() != 5);

System.out.println("Valid word entered!")

How would you draw this algorithm as a flowchart? Use any of the symbols above.

Simplify the input by just using input word

Simplify the output by just using output "Enter 5 letter word:"

Tags

pseudocodeWHILE ... DO ... END WHILE flowchartFOR... END FOR pre-condition loop IF... THEN... END IF count-controlled loop INPUT post-condition loopOUTPUT