[go: up one dir, main page]

0% found this document useful (0 votes)
17 views5 pages

Grade 11 Handout

This document outlines the second week of a problem-solving unit in the Information Technology Department at Mount Alvernia High. It includes lessons on evaluating solutions, understanding constants and variables, declaring data types, and using pseudocode and flowcharts for algorithm representation. Additionally, it provides tasks for students to practice these concepts through practical examples and exercises.

Uploaded by

n8nwryqy4b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Grade 11 Handout

This document outlines the second week of a problem-solving unit in the Information Technology Department at Mount Alvernia High. It includes lessons on evaluating solutions, understanding constants and variables, declaring data types, and using pseudocode and flowcharts for algorithm representation. Additionally, it provides tasks for students to practice these concepts through practical examples and exercises.

Uploaded by

n8nwryqy4b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MOUNT ALVERNIA HIGH

INFORMATION TECHNOLOGY DEPARTMENT


HANDOUT – WEEK 2
UNIT – PROBLEM SOLVING
SEPTEMBER 18-22, 2012

LESSON TWO

1. evaluate alternative solutions to problems and use the most efficient solution
2. explain the difference between constants and variables
3. select and use appropriate data types to declare various variables
4. identify output, input and processing statements with 100% accuracy
5. outline the structure of a pseudocode
6. identify flowchart symbols used to represent the three components of a problem
7. convert algorithm to basic pseudocode(structured-algorithm)
8. apply aspects of problem solving with computing to solve everyday problems
9. show willingness to develop algorithms by asking questions

PROBLEM SOLVING CONTENT – WEEK TWO


TASK 1: Inform a new teacher of a way he/she can get to Nyamings and Jamins Restaurant from Mount Alvernia High?
Propose alternative solutions to the problem and determine the most efficient one.
TASK 2: Consider the algorithm below that reads four numbers, calculated and printed the sum. Can you develop an
alternative solution to the problem? Make your proposal.

SOLUTION 1
1. Start
2. Get the first number
3. Get the second number
4. Get the third number
5. Get the fourth number
6. Add the four numbers
7. Print the total
8. Stop

HINT: In finding alternative solutions, ask yourself:

 could I have used less steps and still solve the problem
 could I have used a different equation and get the same result

Oral Question/Answer: In what ways do you see alternative solutions being proposed and used to solve or attempt to
solve problems at Mount Alvernia as it relates to:

1. Students’ lunch schedule


2. Tastee providing lunch within a specific time.

REPRESENTING AGLORITHMS
Two ways of representing algorithm: Pseudocode (Structured Algorithm) and Flowchart
 Pseudocode is a method of describing computer algorithms using a combination of natural language and some aspects
programming language.
 Unlike pseudocode, flowcharts describe the program flow using symbols that represent each component of the problem.

COMPONENT OF THE PSEDUOCODE FLOWCHART SYMBOLS


PROBLEM
Input Keywords: INPUT, READ
Read Num1, Num2 Num1
Num2

Process Result = Num1 + Num2 Result = Num1 +Num2

Output Keywords: PRINT, DISPLAY


PRINT Result Result

ALGORITHMIC STRUCTURE FLOWCHART

Header: Algorithm’s name or title START


Declaration: A brief description of the algorithm
Declaration of constants
Declaration of variables
BEGIN INPUT
Initializing variables
Prompt/output statement PROCESS
Input statements THE INPUT
…..
…… OUTPUT
Processing statement RESULT
Output statement with result
END
END
CONSTANT
A constant is a value that remains the same throughout the execution of the program repeatedly.
Data that remains constant: PI, minutes in an hour, etc.

CONCEPT OF VARIABLES

A variable is a symbolic name assigned to a memory location to store a particular value. NOTE: Use little or no literal or values in your
codes. Create variables for storage, doing so will allocate space in memory and variables are stored for later use, for printing or use in
subsequent calculations. Variables MUST be declared before they are used otherwise, there will be no location
allocated to store values entered by user, or what the program processes.

 Suitable names to identify the variable to store the first number – NUM1, A or even X
 Suitable names to identify the variable to store the second number – NUM2, A, or even Y
 Suitable names to identify the variable to store the result – SUM, RESULT, ANSWER

A variable must not begin with a number or special characters such as %, #, $...etc
Data that changes: Price, salary, hours worked, etc

DATA TYPES
Data is defined as facts or figures, or information that's stored in or used by a computer. Data can be stored in the form of
text, numbers or characters. A data type is an attribute that specifies the type of data that the variable can hold. Some
basic data types used in programming.

Data Type Description Example Variable Type Use

Integer Whole numbers -1, 0, 2, 39 Age, Quantity, etc when the variable isn’t likely to have
decimal points
Real Numbers with decimal 0.1, 3.4, 5 Price, Salary, Score, etc when the variable may have decimal
points

String More than one character “Bob”,etc Name, Address, etc when the variable will store a word

Char For a character %, a, b,etc Gender, Letter when the variable is likely to store a
letter or symbol
DECLARING VARIABLES

Pseudocode Syntax of Format is: Declare variable as: <variable name> as <data type>

Examples Declare variable salary as real


Declare variable hours_worked as real
Declare variable firstname as string
Declare variable age as integer
Declare variable gender as char

TASK 3: This activity will help you to declare variables using appropriate data type

a) Write pseudocode statements to declare:

a) two integer variables called num1 and num2 and give a sample data for each
b) a variable called average to store the average grade of a student after its being calculated
c) a variable called firstname to store the first name of a student.
d) a variable called age of a student
e) a variable called grade to store the letter grade of a student

b) For each variable, give ONE sample data that the variable may store. Record your result in a tabular format for
part (a) and (b). See sample table below:

Activity: Declaring variables using pseudocode statements

Task Variable Declaration Sample Data to use in


the program
a
b
c
d
e

OUTPUTTING INFORMATION USING PSEUDOCODE


The keywords OUTPUT, PRINT or DISPLAY may be used to output instructions and/ results to the screen. With this
statement, the screen will be blank.

Syntax to instruct/prompt user to enter information into the computer program is: PRINT “String literal”
A "string literal" is a sequence of characters enclosed in double quotation marks (" ");

Example: PRINT “Enter two numbers, separate by a space”

Syntax to output value stored in a variable is: PRINT variable_name E.g. PRINT sum

Syntax to output value in a variable with a string literal is: PRINT “String literal”, variable_name
E.g PRINT “The total is: ” , sum

TASK 4: PAIR ACTIVITY: Write pseudocode statements or instructions to:

a) “Today is Monday”
b) print the value stored in the variable Salary
c) print the value stored in the variable sum with the string literal “The total is =”

INPUTTING DATA

Pseudocode syntax to enable input into variables is: READ variable identifier
E.g. READ name
READ age
READ name, age

The input statement allows the user to enter a value, which corresponds with the instruction given on screen. READ name,
is storing a name in the variable location ‘name’.

TASK 5: This activity will help you write instructions to allow the program to accept values
Write pseudocode statements or instructions to:

a) input a number
b) read the name of a student
c) read the name and age of student in two separate statements (two different steps or lines)
d) read the name and age of a student in one statement (in one step or line)

PROCESSING STATEMENT are statements that perform calculation

Pseudocode syntax to perform calculation is: variable_name assignment operator expression/equation

Psueudocode operator is the backward arrow or the equal sign. Preferably, use the arrow for pseudocode and the equal
sign for Pascal codes.

E.g. total  a + b+ c or total = a + b + c

count  3 count = 3 //initializing the variable count to 3. This means the value 3 is in count
average  total/count average = total/count
Arithmetic Operators: + (addition) ; - (subtraction); * (multiplication); / (division)

TASK 6: This activity will help you write instructions to allow the program to perform calculations and storing
the result in a variable.

Write pseudocode statements or instructions to:

a) calculate the area of a circle


b) determine the circumference
c) calculate the salary of a worker
d) calculate the sum of two numbers

TASK 7: Represent the algorithm below using a full pseudocode and flowchart. Lessen the number of prompt
statements to improve efficiency.

1. Start
2. Get the first number
3. Get the second number
4. Get the third number
5. Get the fourth number
6. Add the four numbers
7. Print the total
8. Stop

HOMEWORK
1. Develop a 1) pseudocode and 2) flowchart to represent the algorithm below:
A customer pays a monthly fee of $37.50 for the telephone service and $3.50 per minute for long
distance calls. Input the number of minutes for a long distance call. Calculate and print the total bill.

2. Complete question 1 in programming workbook.

You might also like