Friday, September 21, 2018

Lab 1 (Week 2 20/9/2018)



Hello Morning ! We had our second lab for computer programming on 20th September. The topic we learnt during lecture is problem solving. Hence, we learnt how to solve problem by running java program for our second lab. For the topic of "Problem solving", problem analysis chart (PAC) is important and used in solving problem. It consists of three components which are data, processing and output for every problem. Input (Data) is required and being processed (processing) to get a solution (output). For analogy, the ingredients we need in baking a cake such as flour, sugar, eggs and milk are our data (input) and the way we bake a cake (recipe) are our processing and finally cake is our output. Let’s look at some questions given by lecturer.
* Input, processing and output is determined by analysing from the question.







Besides, there are few questions given by lecturer for our second lab. After hard work with the help from friends, I am able to solve all question by writing java program successfully. The answers are as following:
* The code must be written in correct format in order to get the correct answer and avoid any error such as syntax, runtime and logic error.


*Different variables must be declared separately. For example, i , j and k must be declared separately in new lines instead of int i = j = k = 2.
* The answer with decimal getting from division of number must be declared using of double instead of int. Otherwise, this will lead to logic error. The answer from5/2 will be 2.
*The declared variables used must consistent with the repeated variables.(The alphabet is sensitive in java). For example, annualInterestRate is not same with annualInterestrate.

(Test 6 and Test 7 : The int datatype only hold numbers from -2147483648 till 2147483647.)
*The runtime error occurs when 1/0 because any numbers is impossible divide by 0.(0 is impossible be divided)
Hence, I changed another number such as 1 to divide in order to run my program.

* Code ", ; , and {} must be given attention.




Hoorayyy ⁂⁂ Finally done !

At the end of the lab, I am able to write java program in solving problem by using Program Analysis Chart (PAC). The codes given by lecturer consist of error such as alphabet, spacing, punctuation and arrangement among words. We need to fix error one by one in order to compile the java file. It was really interesting when doing question because we expect to look forward java file being compiled and solve the problem successfully. We should never give up even command prompt (cmd) keep showing error but instead find another way to solve the problem. Furthermore, we should always practice during free time because Practice Makes Perfect ! Yeah ! Hope to explore more in coming lab. Thank you. Bye♥♥♥ 

Lim Xue Ting
183615
SSK3100 (Group15)

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

No comments:

Post a Comment

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...