Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Assignment 1 TDB 2073 Chemical Engineering Group

Introduction
You are required to write three programs:_ Program 1, Program 2 and Program 3.

Program 1
Write a flowchart and a program that displays a half pyramid.

For student ID with ODD last digit, e.g. 19111, 19001, 20121 etc, the output displayed should be
similar to Figure 1

Figure 1

For student ID with EVEN last digit, e.g. 19112, 19002, 20124 etc, the output displayed should
be similar to Figure 2.

Figure 2

Assignment 1 TDB 2073 Chemical Engineering Group

Program 2
Use SENTINEL to write a program that calculates the total and average of undetermined series
of numbers. The user enters a series of numbers and finally a sentinel value (e.g. 999). Having
entered the sentinel value, the program will instantly calculate the sum and the average of the
numbers. Sample output is as in Figure 3

Figure 3

Assignment 1 TDB 2073 Chemical Engineering Group

Program 3
Program 3 determines the birth state of the user based on his or her Malaysian Identity Card
(IC) number. For example, if a user enters 12-digit IC number 120488145667, the program will
extract the 7th and 8th digits, i.e. 14. It refers to the state codes in Figure 4 and displays
Wilayah Persekutuan as the birth place of the user.

Figure 4

A sample output is shown in Figure 5.

Figure 5

Assignment 1 TDB 2073 Chemical Engineering Group

Submission
You are required to name the programs as follows:

Program 1

studentIDnumber_halfpyramid.cpp

Program 2

studentIDnumber_sentinel.cpp

Program 3

studentIDnumber_statecode.cpp

Compress all three files in a zip file. Name the zip file as follows:
studentIDnumber_CE_Assignment1.zip

Due date for the submission is Monday


to be done through e-learning.

17 August 2015 before 5pm. Submission is

You might also like