0% found this document useful (0 votes)
66 views10 pages

Lab 1 (Program Design)

This document contains exercises from a programming lab on basic programming concepts. The exercises cover topics like identifying inputs and outputs, naming variables, drawing flowcharts to solve problems using basic control structures like sequence, selection, and repetition. Sample problems include converting between units, determining street directions based on street numbers, calculating parking fees, grading systems, and arranging photos on paper. The goal is for students to understand fundamental programming techniques.

Uploaded by

:]
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)
66 views10 pages

Lab 1 (Program Design)

This document contains exercises from a programming lab on basic programming concepts. The exercises cover topics like identifying inputs and outputs, naming variables, drawing flowcharts to solve problems using basic control structures like sequence, selection, and repetition. Sample problems include converting between units, determining street directions based on street numbers, calculating parking fees, grading systems, and arranging photos on paper. The goal is for students to understand fundamental programming techniques.

Uploaded by

:]
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
You are on page 1/ 10

asdHong Kong Institute of Vocational Education

IT114105 HD in Software Engineering


IT124106 HD in Computer Systems Administration
ITP3914 Programming
Topic 1: Basic Programming Concepts
Lab 1 – Program Design
Intended Learning Outcomes
Upon completion of this tutorial/lab, you should be able to:
o Identify inputs, outputs, and processing components from a problem description.
o Work out solution steps for the defined problem with sequence, selection and repetition control
structures.

Exercise 1

List the seven basic steps in computer program development.

1. Define the problem


2. Outline the solution
3. Turn the outline inro stopes for solving the problem
4. Test the steps for correctness
5. Code the steps into a targeted programming language
6. Run the program on a computer
7. Document and maintain the program
Exercise 2

What are the inputs and outputs of the problems below?

(a) Calculating the area of a triangle

Input: Base, height

Output: Area of a triangle

(b) Calculating the solution(s) of a quadratic equation

Input: a, b, c

Output: the value of ‘x’

(c) Measuring the distance of two cities on Earth


1
Input: Tow cities Latitude and longitude

Output: the long between two cities

Exercise 3

Suggest suitable names for variables storing the data below.

(a) A student’s English name

engName

(b) The examination mark of a student in the module “Programming”.

examMark

(c) A student’s ID number

idNum

(d) Number of items in a shopping cart

itemsInCart

Exercise 4

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: Convert a length in inches to centimeters (1 inch = 2.54 cm).

2
Exercise 5

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: In New York City (NYC), even numbered streets are east-bound, odd numbered streets
are west-bound. Given a street number of a street in NYC, decide the direction of the street, either east-
bound or west-bound. Print a message on screen to tell the user the direction.

3
4
Exercise 6

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: Calculate the parking fee based on the vehicle type and the hours a vehicle spent in a car
park. The parking fee is charged according to the table below.

Vehicle Type Hourly Rate ($ per hour)


Private Car 15
Bus 35
Truck 50

5
Exercise 7

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: Input an examination mark (0-100) and determine the grade (A to F) obtained according
to the table below.

Mark 0-59 60-69 70-79 80-89 otherwise

Grade F D C B A

6
Exercise 8

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: As the user to input a positive integer value (n) and then displays ‘*’ times on the screen.
A sample execution is shown below.
Please input a positive integer: 5
*****
HINT: Use the repetition construct. At each iteration, you need to determine if enough ‘*’ have been
printed.

7
8
Exercise 9

Draw a flow chart to illustrate how the problem below can be solved. Specify clearly the input, process,
and output steps with correct flowchart symbols.

PROBLEM: Given the width and length of a piece of rectangular paper, determine the maximum
number of small-size rectangular photos that can be printed on it. The photos can be arranged either in
portrait or landscape.

Portrait arrangement:

Landscape arrangement:

9
END.

10

You might also like