Monday 14 January 2019

LAB5

hallo !
i'm back for the reflection of lab5 :)
so, the topic for lab5 in week 6 is switch statement, logical operators and conditional operator. In this lab, i should be able to use switch statement to specify alternative paths of program's execution. Then, i should be able to use logical operators to combine Boolean expressions. Lastly, i should able to use the conditional operators for concise and elegant code for decision making.

To complete this lab exercise, i have to know what is switch, logical operators and conditional operators. The question asked me to rewrite the if-else statement using switch statment. As i know, by implementing if-else statement, it tells the computer if the condition is true, then execute the a set of instructions or else execute another set of instructions. for the switch statement, it is made up of several or many set instructions which is only one will be selected by the user and executed by the computer.

This is the question where i have to rewrite the if-else statement using switch statement. As we can see it is more simple. In switch statement , i need to include switch expression where "a" is my switch expression in this question.  For the case statement, it represents if-else statement. The statement are executed when the value in the case statement matches the value of the switch expression. Every case statement should have break or continue at the end in order to terminate the remainder of the switch statement. If there is no break, the next case statement will be executed.  Switch statement is useful when we have constant variable and only selected case statement be executed. After knowing this switch statement, i able to convert back the statement into if-else statement. I have to know and understand the basic algorithm of switch statement. 

Then, the other questions asked me to rewrite the if statements using the conditional operator. 
This is one of the example of converting if statements using conditional operator. From 4 lines of statements become one line statement. For conditional operator the statement is " (booleanExpression) ? expression1 : expression2 ". So in the question ages is the booelan expression. We check the boolean expression either the ages is a true condition or false. The expression1 is for true statement while expression2 is for false statement. 3 operands in one statement. 

From this basic understanding i can include this logic structure in problem solving which i have to know when to put identify if it suitable or not. So i have to understand clearly. 

Friday 14 December 2018

LAB 4

Welcome to my blog :)

This is time i learnt about Multi-way and nested selections !
I learnt to use multi-way and nested selection statement to specify alternative paths of program's execution. Before this, i have learned one way if statement and this time i can do two way if statement. In this two way if statement, it could be another statements for true case in one problem. This two way statement allow us to create multiple choice or decisions.

In order to apply this two way if statement, we have been asked to create our own game. ouh yeahhh it is interesting. i have created my own story which i clearly can see the function of this two-way if statement. hiks :)

LAB 3

Dinie is here !

So do you know what topic it is for Lab 3?
The topics are problem solving, data types and selection.

So what is data types? i have mentioned in previous post that the example of data types are Byte, Long, String and others. Let me share the information one of data types. So we know that number consists of integer, decimal, whole number and number also have minimum value maximum value. To create a program we have to make sure what kind of variable that we have. If the variable is an integer the data type is byte, if the variable is decimal the data type is double. You have to identify the variable to know the data type. This is basically the basic/primitive data type.

As usual, in this lab i trace the program given. This time is different as we are using different data type and we need to make sure the program is using the correct data type. Then i need to correct if the data type is wrong.

This time, the question for creating a program for the problem is quite difficult. This is beacuse the problem given quite difficult. I took a longer time than before as i need to learn more about the terms terms such as data types, relational and comparison operators to test some kind of relations between two entities such as ==, -= and etc. This kind of comparison operators is used in certain kind of program.

During lab 3, i have learnt to declare, initialize and use appropriate data types in program. To specify alternative paths of program's execution i have to use selection statement. Then after knowing and master all of this i have to write and practice more to run this simple computer program. Exercise in this lab manual is verry helpful !

LAB 2

Holla Holli Hullu !

Hi guys, i'm going to share what i have learnt during lab 2. this is the very late post to do my reflection and sorry for that. This is because i keep doing my coding and forgot to do the reflection. Sorry Dr Erzam :)) hihihihihi

So the topic for lab2 is problem solving. At the end of this lab, all of us should be able to trace a program and designing solution to a problem using PAC and IPO. From the previous post i have shared what is PAC. For IPO it is stand for Input Process Output Chart. IPO is almost likely to PAC. It only have a little bit different as IPO is more details than PAC. In PAC we just analyse the problem generally while IPO we put all the details in each input, process and output. So for those who wants to know or and learn more about this you can straightly google it and you can see the difference. after learning IPO, i should be able to write, compile and run a simple computer programme based on IPO.

Here we go !
This lab consists 6 questions. For the first question, we have to trace the programme and show their ouput. I need a Trace Program Table to trace the program given. To trace the program, we have to through line by line. Write a line that contain value and show the output.

After tracing each program, i need to identify the error in the program. This is where we can find the error and correct it. While tracing the program, we will know each error and the error can be logic error.

For the next questions i have to be able analyse the probem given using PAC and IPO. I need to the PAC and continue for IPO. IPO we refer to the PAC and come out with all the details. Then, i have to create Java program and run. I want to say that this method is really helping me in designing solution for the problem.

There is also a program that using different variables according to the input. The variables i mentioned is the data type such as Byte, Long, Double and others.

so lets move to the next lab.



LAB 1

Ouh hye, Dinie is back. Last Tuesday on 25th September, we proceed to next lab. This time the topic is about problem solving. After getting used with programming environment, we need to be able to identify common errors and programming pitfalls. Means that we were given all the coding and need to follow the programs but there are some errors inside the coding and we need to identify and fix by ourselves. So, at the first I just try the wrong coding that given and found out that the Java cannot run the program even there is only one error. To make it clear lets go through all the tests one by one.

Test 1

Test 2

Test 3

Test4
Test5

these are some of examples that we try to fix the errors. By doing this, we know the errors we shoud avoid while doing the coding. This is important to make sure the programme we create is running and success. 

For the question 2, we have to analyze the problem using PAC. PAC is stand for Problem Analysing Chart. This PAC is helpful as it help a lots in jotting down all the requirements needed to do coding. It organised our process while creating the program. In PAC, we need to list out the data, processing and the output. By referring the PAC, we can proceed to do the flowchart and coding.

So we applied the PAC in question 3. We need to choose one of the problem given and used the complete Java program to solve it. While doing this question, it makes me know what is the input that i need to know and what is the process of the program so that the output is print out succesfully.

In this lab, i need to improve and do more practice so that i can easily creating Java program to solve any problems !


Saturday 22 September 2018

0 LAB

Assalamualaikum and hye everyone.

My name is Dinie Filzahie Binti Kamaruddin and taking instrumentation science course. So this semester i'm going  to learn conputer programming 1 subject.

On 18th September 2018, I attend my first lab in computer programming 1 subject. In this first lab, we have been introduce in programming environment . As a student who has zero knowledge about programming i find out that programming is quite interesting as i can even create a folder by using command prompt and typing out the command. What i learnt is if i want to create a new folder using command prompt i have to command by typing 'mkdir your_name' . Command 'cd' is use if you want to go back to your parent directory. After getting used with some of coding and the command, i learnt to write, compile and run a simple computer program written in java.


As i know javac function is used to compile the code which we have written for a program.
During lab, we have been told by lecturer before using the javac we have to check if the pc we use has the java file or not. In this part, i'm a little bit lost since i do not what to do next. So after figure out why my javac is not found or cannot be recognized , i have to set the path for my java. There are some steps to do to which is i already know and learnt from google and my friends in the lab. Then i proceed my simple java program using notepad and typing all the code that instructed in lab manual and name the file "MyFirstJavaProgram.java. so to compile this java program i have to command javac MyFirstJavaProgram. To run the program i typing out the command "java MyFirstJavaProgram".
The result will come out  according to the program that i have coded.




This is the result from my java program. I started by organized my files in specific folder. I save my java program in lab0 folder. By following all the steps in lab manual i managed to make my 'hello world' appear. Not to forget, i make some mistakes during my first lab. As i succesfully run the java program, i started again with different code of output and failed. I figured out that i make a spelling error and wrong current directory. Then i know even we coded wrongly we also cannot run our program. So coded carefully and make sure to follow step by step . can't wait for next lab !


Xinyee

LAB5

hallo ! i'm back for the reflection of lab5 :) so, the topic for lab5 in week 6 is switch statement, logical operators and conditional...