Sunday, November 11, 2018

Lab5

Assalamualaikum, in this entry i would like to share about lab5 only. this week i only finish my lab5 . the entire three hours, i spend to finish my lab5 only. lab5 is about the switch statement, logical operator and conditional operator.

first, switch statement is something like the if-else statement, just the way to write it is different but the output is the same. switch statement also need to use scanner as we need to get the command from the keyboard. the example of switch statement is like this:


import java.util.Scanner ;
public class Month {
    public static void main(String[]args){
      Scanner input = new Scanner(System.in);

      System.out.print("Enter number 1 until 12 only :");
      int x = input.nextInt();

  
   switch(x) {
     case 1 : System.out.println("january");
                   break;
     case 2 : System.out.println("february");
                   break;
     case 3 : System.out.println("march");
                   break;
     case 4 : System.out.println("april");
                  break;
     case 5 : System.out.println("may");
                  break;
     case 6 : System.out.println("june");
                  break;
     case 7 : System.out.println("july");
                  break;
     case 8 : System.out.println("august");
                  break;
     case 9 : System.out.println("september");
                  break;
     case 10 : System.out.println("october");
                  break;
     case 11 : System.out.println("november");
                  break;
     case 12 : System.out.println("december");
                  break;
     default : System.out.println("error");
}

}
}

from the example, we need the command from the keyboard which is number 1 to 12, when the number is selected, it will print out the result based on the month assigned for the umber selected. if the number is out of the range, it will print out 'error'.

next is about conditional operator combine with Boolean expression. for example for this case is like:


ticketPrice = (ages >= 6) ? 20 : 10


from the example we can know rhat if the ages is more than or equal to 6 years old, the ticket price is RM 20 or else if ages is less than 6 years old, the ticket price will be RM 10.

that is all for this entry. thank you.


p/s: link to Atika`s blog
ssk3100.blogspot.com


Lab4 & Lab5

Assalamualaikum, in this entry I would like to share about the lab4 and lab5. In the lab4 there is only one question which is to create our own adventure game. In this lab we need to use multi way and nested selection. means that player need to choose between two option, then form the option, we need to create another scene consequences from the player answer. there need to be two endings.

Next is about lab5, in this lab we need to know how to use switch statement, logical operator combine with Boolean expression and conditional operator. switch statement is like the if - else statement, the difference is that switch does not use 'if ', the use 'break' to separate the command. for the conditional operator, it also same as the if-else statement, but the difference is that conditional operator combine the if and else result in the same statement. for example :

score = ( x > 10 ) ? 3 * scale : 4 * scale;

from this statement, we can figure out that    
 if (x > 10) 
score = 3*scale
else
score = 4*scale;

that is all i want to share for this entry. thank you.

Test one is being held in this same week. For test one basically is not too difficult but it become difficult because there is not enough time to properly look through the questions and I answer the questions hurriedly. For me, the time for the test should be extent 30 minutes approximately.


p/s: link to Atika`s blog
ssk3100.blogspot.com

Lab3 & Lab4

Assalamualaikum , in this entry I would like to share about lab3 and lab4. For lab3 , is just the same as lab2 but there is an addition in selection statement, declare and use a appropriate data types in program and write, compile and run a programcbased on flowchart.

Firstly, we are been asking to trace a program. Then compile the program and try to run the program. Also , there is some error in the question and we need to fix it before run the java program.

After that, the question is about how to write a java program which is require us to use to the math.pow and also scanner obviously.

for lab4, we learn how to use the multi way and nested selections. Multi way means that the output can be various and not only one possibility on output but there are more than two output .



p/s: link to Atika`s blog
ssk3100.blogspot.com

Sunday, October 21, 2018

Lab2

Assalmualaikum, in this entry I will share about what we learn in lab2 which is about problem analysis chart (PAC) and input process output (IPO).
also , we laern how to write , compile, and run a simple java program.

There is some question in this lab that require us to use the scanner because we need to input some variable which is not a constant value. This type of program a little bit confusing and a bit difficult for me to understand at first, but after doing it for some time , I able to understand a little bit how to use the scanner in java.

We need to use this scanner when there is variable that we want to calculate or want to convert something to other thing. for example in this lab, we need to calculate a BMI. Means that there is variable that we need to input to calculate the BMI. The variable is changes and does not constant. Hence, in this case we need to use scanner.

That is all from me for this entry. thank you.

p/s: link to Atika`s blog
ssk3100.blogspot.com

Monday, October 1, 2018

Lab1

Assalamualaikum, so this entry is about my second class of computer programming. in this class we are asked to type the test given, then we have to compile and try to run the program. To compile a program, we have to type 'javac Test1', then if there is some error it cannot be compile, it will pop out our mistake instead. So we have fix the problem until it can be compile. Unfortunately, there is some errors that cannot be fix or solved such as logic error. for example :

image.png

If the question is given like this one, which means that it cannot be solved even by using calculator, so it called logic error. So when we want to run the program, it will turn out like this:

image.png

In the questions given, there is different error or there is no error at all. We as the student need to know where is the error and know how to solve it until the program can be compile. After we solve the problem and can be compile, we have to check weather it can be run or not by typing 'java Test'.

How to solve all the problem is based on the program analysis chart. it is something like this:
Image result for problem analysis chart programming
I find that it is easier to use this method when having programming problem. because when we use this method, we will write it in order. So it is easy to see where is the mistake and easy to fix it.

That is all for this entry. Thank you.


P/S: Link to Atika's blog
ssk3100.blogspot.com

Saturday, September 22, 2018

Lab0


Part 1

Assalamualaikum, in this post I would like to share about my computer programming SSK3100 class . This is my our first class, so we just learn some basic stuff about the command prompt.

firstly, in the computer lab , our lecturer teach us how to open the command prompt and navigate ourself by typing `dir` thtough all the folders in the computer. How to enter some specific file is by typing `cd name of the file`, then enter , it will automatically open the file.

After we have familliar ourself with the command prompt, our lecturer ask us to make our own file by using this command prompt. The step is we have to type`mkdir our name` then enter. it will automatically create the folder. then , we have to make another file within our name file which is the Lab0 file. The step to make this file is just the same as to make our own file. Then, we also create a file called notepad in the Lab0 file.

Next, we have to check whether the computer got the latest version of java or not. how to know it , we have to google it. then from there we will know what is theatest version of java. After checking the java version, our lecturer ask us to compile the java by using command prompt so that we can use it anywhere in the computer.

To compile the java, we have to make our own java program. by using the notepad, we just type `myfirstjavaprogram` then save it in the Lab0 file. But to open it , we have to type `javac myfirstjavaprogram` in the command prompt.

When we want to compile the java file, make sure there is no typing error. If there is any typing error, in the command prompt, it will tells you what is the error then you have to rewrite the terms until there is no error. After you finished fix the error, only then it can be compile , otherwise it will pop out the errors.


Part 2

Assalamualaikum , this is my second entry. in this entry, I would like to share about the first lecture of my computer programming class. For the first class, as usual we learn the first topic for this subject.

Its the same topic as we learn in the lab. the difference is in the lab we practically learn how to do it but in this lecture we just learn it theoretically how it works.

what makes it interesting is , our lecturer ask us how is the image and music are stored in the computer. As we know that computer system can only reads a binary number and the arithmetic. So the question is how the computer system can keep the image , music and even how the letter can be keep as well.

So to find these answer, I google it and I found the answer. I found that actually the image already have the fix number for the pixels by the column and row. Normally this pixels are keeps in computer as raster image where these values are stored in compressed form.

Then , for the colour image, there is actually a tiny square of colour which is composed by pixels together. Pixels contain specific number and that number represent each colour.

Next is about music. We know that music travel as a wave. Since it in wave form and computer can only store data in number, so we have to manipulated the sound so that it will be stored in digital form. So when we keep the sound in computer, it will be converted to digital from analog and when we want to play it, it will be converted back to analog from digital.

Hence , that is my answer for the question how do the music and picture are stored in computer.

p/s: link to Atika`s blog
ssk3100.blogspot.com