0% found this document useful (0 votes)
14 views37 pages

Problem Solving with Flowgorithm Basics

The document outlines a problem-solving approach using the Input-Process-Output (IPO) model in computing, focusing on practical examples like calculating employee pay and managing student records. It introduces tools like Flowgorithm for visual programming and covers essential programming concepts such as variables, data types, arithmetic operations, and algorithms. Additionally, it presents case studies for a student management system that includes fee calculations and marks recording, emphasizing input handling and output formatting.

Uploaded by

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

Problem Solving with Flowgorithm Basics

The document outlines a problem-solving approach using the Input-Process-Output (IPO) model in computing, focusing on practical examples like calculating employee pay and managing student records. It introduces tools like Flowgorithm for visual programming and covers essential programming concepts such as variables, data types, arithmetic operations, and algorithms. Additionally, it presents case studies for a student management system that includes fee calculations and marks recording, emphasizing input handling and output formatting.

Uploaded by

rr54848444
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROBLEM SOLVING

INPUT – PROCESS - OUTPUT (IPO)


CP1013
INTRODUCTION TO COMPUTING

Week 02
Brainstorming Time (15 mins)
Keeping in mind, Computers don’t vibe with guesses; they need only data. Let’s fix this by solving a
problem
Goal:
Using three unmarked buckets and only the allowed moves,
Classic Problem
get exactly the target amount in any one bucket.
Capacities: 8L, 5L, 3L
Allowed moves: Target: 4L in 5L bucket
[Link] any of the buckets to the top from the tap.
[Link] a bucket into the drain. Hint 1: Try to leave 1L somewhere; it helps create 4 on the
[Link] from one bucket to another until the source is empty
next move.
or the target is full.
Hint 2: Keep tracking with states—don’t rely on memory.

No guessing partial amounts; no other tools/marks.


Today’s Content
• Introduction to Flowgorithm Tool (for Visualization)
• Variables and Literals
• Datatypes
• Arithmetic Operators
• Expressions evaluation and calculation
• Input and output
• Case Studies
Flowgorithm
This tool helps you!
• Flowgorithm lets beginners think in steps without syntax drama.

• We’ll learn the symbols, then build tiny programs using variables,
expressions, and I/O (input/output).

• Flowgorithm is a free, beginner-friendly visual language that teaches


programming through flowcharts instead of syntax-heavy code.

• It lets students run their logic directly, focusing on concepts first and
avoiding early frustration.
Flowchart (Quick Recap)
• A graphical representation of an algorithm.
• Remember the Symbols now
Go with the Flow
Each problem goes through the same kind of flow:

Input Output
Process

Input is received Some process is performed on the input Output is produced

Example (Calculate Pay of an Employee):


Variables and Literals
➢ A variable is a named storage box with a datatype.
➢ A literal is a fixed value you write directly (e.g., 42, 3.14, "Hi", true).

Example (Calculate Pay of an Employee):


Variables Literals
HourlyPayRate 800.50
HoursWorked 8
GrossPay 6404.00
Datatypes
➢ The common datatypes we are going to use are: integer, string, boolean, and
real
Type What it holds Example literal
Integer whole numbers 12, -5
Real decimals / measurements 3.5, 0.08
String text in quotes "Hello"
Boolean truth values true, false

Example (Calculate Pay of an Employee):


Variables Type Literals
HourlyPayRate Real 800.50
HoursWorked Integer 8
GrossPay Real 6404.00

For more information, visit: Flowgorithm - Documentation - Assign


Arithmetic Operators
➢ We’ll use: + - * / % and (optionally) ^ for exponent.
➢ + add, - subtract, * multiply, / divide, % remainder (mod).
Examples:
✓ sum = a + b
✓ discount = subtotal * 0.05
✓ ratio = x / y
✓ remainder = x % 10
✓ area = width * height
✓ power = 2 ^ 3

Example (Calculate Pay of an Employee):


Variables Type Operators Literals
HourlyPayRate Real 800.50
HoursWorked Integer 8
GrossPay Real HourlyPayRate 6404.00
* HoursWorked
For more information, visit: Flowgorithm - Documentation - Expressions
Expression Evaluation and Calculation
Example Expression 01:
x = 3 + (4 * 2 ) % 5

x = 3 + 8 % 5

x = 3 + 3

x = 6

For more information, visit: Flowgorithm - Documentation - Expressions


Expression Evaluation and Calculation
Example Expression 02:
p = 2 ^ 3 * 2

p = 8 * 2

p = 16

For more information, visit: Flowgorithm - Documentation - Expressions


Let’s Practice!
Expression Value

(5 + 2) * 4 ______________________

10 / (5 - 3) 5 ______________________

8 + 12 * (6 - 2) ______________________

(6 - 3) * (2 + 7) / 3 ______________________

For more information, visit: Flowgorithm - Documentation - Expressions


Input & Output (I/O)
➢ Input: reads from the keyboard into a variable.
➢ Output: prints to the console

Example
(Calculate Pay of an Employee)

Input: HourPayRate, HoursWorked


Process: TotalPay= HourPayRate * HoursWorked
Output: prints TotalPay
Let’s Put it All Together
Example A: Bookstore

The bookstore needs a tiny tool for exactly three items. The cashier
enters the price and quantity for each item. The program computes the
subtotal, adds a fixed 8% sales tax and a fixed PKR 50 service fee,
and prints the final payable amount. No discounts or choices, just
straight calculation.

Circle ones are the variables, and the underlined ones are the actions (process)
Step 1: I-P-O-C-E

• Inputs: price1, qty1, price2, qty2, price3, qty3

• Process: tax = subtotal × 0.08; final = subtotal + tax + 50

• Outputs: subtotal, taxAmount, finalAmount

• Constraints: numeric inputs; exactly 3 items

• Edge cases: none special (no branching)


Step 2: Algorithm

• Step 1: Input price1, qty1, price2, qty2, price3, qty3

• Step 2: item1 ← price1 × qty1, item2 ← price2 × qty2, item3 ← price3 × qty3

• Step 3: subtotal ← item1 + item2 + item3

• Step 4: taxAmount ← subtotal × 0.08

• Step 5: finalAmount ← subtotal + taxAmount + 50

• Step 6: Print subtotal, taxAmount, finalAmount

• Step 7: End
Step 2: Pseudocode
INPUT price1, qty1, price2, qty2, price3, qty3
SET TAX = 0.08, FEE = 50.00
item1 ← price1 * qty1
item2 ← price2 * qty2
item3 ← price3 * qty3
subtotal ← item1 + item2 +item3
taxAmount ← subtotal * TAX
finalAmount ← subtotal + taxAmount + FEE
PRINT subtotal, taxAmount, finalAmount
Step 3:
Flowchart
Example B: Team Average
(Try to do it yourself)
A college wants you to design a solution for them that will calculate the
average number of wins for their football team over the past five years.
The user of the program should be able to enter the number of wins
each year. The program will calculate the average number of wins
during that five-year period and display that information on the screen.
IPOCE
I (Inputs): wins1, wins2, wins3, wins4, wins5
P (Process): totalWins = wins1 + wins2 + wins3 + wins4 + wins5; averageWins = totalWins / 5
O (Outputs): averageWins (Real) with message: “Average wins over 5 years: <averageWins>”
C (Constraints): Exactly 5 inputs; wins are whole numbers ≥ 0
E (Edge cases): All zeros (average = 0), very high single-year value, missing/negative/non-numeric input

Algorithm
Step 1: Start
Step 2: Input win1, win2, win3, win4, win5
Step 3: Set total ← win1 + win2 + win3 + win4 + win5
Step 4: Set average ← total / 5
Step 5: Output “Average wins over 5 years: ”, average
Step 6: End
Pseudocode Flowchart
DECLARE win1, win2, win3, win4, win5 : Integer
DECLARE total : Integer
DECLARE average : Real

INPUT win1
INPUT win2
INPUT win3
INPUT win4
INPUT win5

total ← win1 + win2 + win3 + win4 + win5


average ← total / 5
OUTPUT "Average wins over 5 years: ", average
END
Let’s Solve a Real-Life Example
Case Study: Student Management System (Add
Record of a Student)

The University of Central Punjab (UCP) requires a simple system to maintain the basic

records of its students. The system should allow the entry of essential details such as

the student’s ID, full name, and department. Once the information is entered, the

system must display the same details back to the user in a clear and organized manner.

This basic record management task will serve as a foundation for understanding how

data can be input, stored, and retrieved.


IORCE
I (Inputs): Student ID, Name, Department
P (Process): ID as integer, Name as text, Department as text
O (Outputs): Display entered details clearly
C (Constraints): No negative/zero value of ID, No null value in name and department variables
E (Edge cases): Missing input, wrong ID format, invalid department

Algorithm
Step 1: Start
Step 2: Input Student ID, Student Name, Student Department
Step 3: Store ID, Name, and Department in variables
Step 4: Display the stored Student ID, Student Name, Student Department
Step 5: End
Flowchart
Pseudocode
Start
Declare integer StudentID
Declare string StudentName
Declare string Department
Print "Enter Student ID:"
Input StudentID
Print "Enter Student Name:"
Input StudentName
Print "Enter Student Department:"
Input Department
Print "Student Record:"
Print "ID: " + StudentID
ToChar(13)
Print "Name: " + StudentName Is the function to
shift the statement
Print "Department: " + Department to next line in same
output
End
Case Study: Student Management System (Fees
Calculation)
The University of Central Punjab (UCP) requires a simple system to manage the basic records of its
students. The system should allow the entry of essential details such as the student’s ID, full name, and
department. Once the information is entered, the system must display the details back to the user in a
clear and organized format. To extend the system further, each student also needs to enroll in five
courses. Every course has credit hours associated with it, and the fee is charged at a fixed rate of
₨18,200 per credit hour. The program should accept the number of credit hours for Course1 through
Course5, calculate the individual fee for each course by multiplying credit hours with the per-hour fee,
and finally display the total fee for all five courses. This case allows students to practice input handling,
basic arithmetic operations, and output formatting while understanding how real-world billing systems
work in an academic context.
IORCE
Input: Student ID, Name, Department, Credit hours of 5 courses
CH1,CH2,CH3,CH4,CH5)
Process: Unique ID, Fee = Credit hours × 18,200, all 5 courses required
Output: Display Student record, each course fee, and total fee
Constraints: ID not empty/negative, Name not blank, Credit hours > 0
Edge Cases: Missing details, non-numeric input, invalid credit hours
Algorithm
Step 1: Start
Step 2: Input Student ID, Student Name, Student Department, Credit Hours
Step 3: Store Student ID, Student Name, Department and Credit Hours in variables
Step 4: Input credit hours for 5 courses in CH1,CH2,CH3,CH4,CH5
Step 5: For each course, calculate course fee = credit hours × 18,200
Step 6: Add all course fees to find the total fee
Step 7: Display the stored Student ID, Student Name, Student Department
Step 8: Display individual course fees
Step 9: Display the total fee
Step 10: End
Pseudocode Fee1 = CH1 * PER_CREDIT
Fee2 = CH2 * PER_CREDIT
Start Fee3 = CH3 * PER_CREDIT
Declare integer StudentID Fee4 = CH4 * PER_CREDIT
Declare string StudentName, Department Fee5 = CH5 * PER_CREDIT
Declare integer CH1, CH2, CH3, CH4, CH5
Declare integer Fee1, Fee2, Fee3, Fee4, Fee5, TotalFee TotalFee = Fee1 + Fee2 + Fee3 + Fee4 + Fee5
PER_CREDIT = 18200
Print "Student Record:"
Print "Enter Student ID:" Print "ID: " + StudentID
Input StudentID Print "Name: " + StudentName
Print "Department: " + Department
Print "Enter Student Name:"
Input StudentName Print "Course1 Fee: " + Fee1
Print "Course2 Fee: " + Fee2
Print "Enter Student Department:" Print "Course3 Fee: " + Fee3
Input Department Print "Course4 Fee: " + Fee4
Print "Course5 Fee: " + Fee5
Print "Enter credit hours for 5 courses:"
Input CH1, CH2, CH3, CH4, CH5 Print "Total Fee: " + TotalFee
End
Flow Chart
Case Study: Student Management System (Course Wise
Marks Calculator)
The University of Central Punjab (UCP) requires a simple system to manage the basic records of its
students. The system should allow the entry of essential details such as the student’s ID, full
name, and department, and display these details back to the user in a clear format. To extend the
system further, each student also needs to enroll in five courses. Every course has credit hours
associated with it, and the fee is charged at a fixed rate of ₨18,200 per credit hour. The program
should accept the number of credit hours for Course1 through Course5, calculate the individual
fee for each course, and then display the total fee for all five courses. Additionally, the system
should record the marks obtained in each of the five courses. The program will input the marks for
Course1 through Course5 and display them back. It should then calculate the total marks
obtained by summing the marks of all five courses, and further compute the average marks by
dividing the total marks by 5.
IORCE
Input: Student ID, Name, Department, Credit hours for 5 courses, Marks for 5 courses
Process: Fee = Credit hours × 18,200; Total Marks = sum of 5 courses; Average = Total/5
Output: Student record, Course fees, Total fee, Marks of 5 courses, Total marks, Average
marks
Constraints: ID not empty/negative, Name not blank, Credit hours > 0, Marks between 0–100
Edge Cases: Missing input, invalid department, non-numeric credit hours/marks, marks <0
or >100
Algorithm
1. Start
2. Input Student ID, Name, Department
3. Input credit hours for 5 courses
4. For each course, calculate fee = credit hours × 18,200
5. Find total fee by summing all course fees
6. Input marks of 5 courses
7. Display marks of each course
8. Calculate total marks = sum of 5 course marks
9. Calculate average marks = total marks ÷ 5
10. Display Student details, course fees, total fee, total marks, and average marks
11. End
Pseudocode

Print "Enter marks for 5 courses:"


Start Input M1, M2, M3, M4, M5
Declare integer StudentID
Declare string StudentName, Department TotalMarks = M1 + M2 + M3 + M4 + M5
Declare integer CH1, CH2, CH3, CH4, CH5 AverageMarks = TotalMarks / 5
Declare integer Fee1, Fee2, Fee3, Fee4, Fee5, TotalFee
Declare integer M1, M2, M3, M4, M5, TotalMarks, AverageMarks Print "Student Record:"
Constant PER_CREDIT = 18200 Print "ID: " + StudentID
Print "Enter Student ID:" Print "Name: " + StudentName
Input StudentID Print "Department: " + Department
Print "Enter Student Name:"
Input StudentName Print "Course1 Fee: " + Fee1
Print "Enter Student Department:" Print "Course2 Fee: " + Fee2
Input Department Print "Course3 Fee: " + Fee3
Print "Enter credit hours for 5 courses:" Print "Course4 Fee: " + Fee4
Input CH1, CH2, CH3, CH4, CH5 Print "Course5 Fee: " + Fee5
Fee1 = CH1 * PER_CREDIT Print "Total Fee: " + TotalFee
Fee2 = CH2 * PER_CREDIT
Fee3 = CH3 * PER_CREDIT Print "Marks: " + M1 + ", " + M2 + ", " + M3 + ", " + M4 + ", " + M5
Fee4 = CH4 * PER_CREDIT Print "Total Marks: " + TotalMarks
Fee5 = CH5 * PER_CREDIT Print "Average Marks: " + AverageMarks
TotalFee = Fee1 + Fee2 + Fee3 + Fee4 + Fee5 End
Flow Chart
Home Task
Fill the Worksheet Attached:

Click on the link -> Practice Worksheet

You might also like