Friday, September 28, 2018

Lab2 (Week3 27/09/2018)

Hello everyone, today we had our third lab for computer programming. The course is becoming more interesting since the questions are more challenging. :-D
During lecture, we learnt what is trace program table. A trace program table is a technique used to test algorithms, in order to make sure that no logical errors occur while the algorithms is being processed. First, we tried to trace some programs. The answers for few questions are as below:

Second, we found there were some error in program Average and FahrenheitToCelsius. We correct it and run again in command prompt and finally correct answer being displayed in command prompt. Hence, data types and operators are very important in getting correct answer.


Third, in class SalesTax in Q(1), the code in line 6 rounds down tax to two decimal places. If tax is 3.456 for example, it would be round down to 3.45.  We were asked to correct line 6 so that tax can be rounded up. We just need to change data type of int to double and add .0 to 100. The answer is shown as below.

Fourth, we were asked to write a program that declares variables and assign values from a user for each data type available in Java and print them out. I used program ComputeArea as example. Let's see how to declare variables and assign value.

For the last two questions, we were asked to write down the PAC, IPO and the algorithm for the program and a complete Java program to solve the problem. IPO is Input Process Output which extends and organises the information in the PAC while algorithm (pseudocode) means an imitation computer code. The answers are shown as following. 




 In short, I am able to trace the program and know how to write IPO. After that, I understand how to draw the program flowcharts and write algorithms. Flowchart is the logical design of a program. It must be drawn according to definite rules and utilizes standard symbols adopted internationally.For example, "oval" is used to indicate the beginning and ending of a set of actions of a program while "rectangles" is used to indicate a process such as calculations. After knowing all of this, we learnt to transcribe the algorithm to program code and run the program code using Java. That's all for today. How you think in your mind? Welcome to comment.

Computer Programming makes fun ! See u again after our next lab. Byee ...

Lim Xue Ting
183615
SSK3100 (Group15)

Next blog: hennyabigail.blogspot.com (Henny Abigailwillyen Sinjus)


Lab 10 (Week 13 13/12/2018)

Heyyy, we had lab 10 which is our last lab. It is about two dimensional array. What is two dimensional array?? Let me explain it ! The e...