Tuesday, October 2, 2018

Lab 1

This is the second lab for this course and it become complication since I never learnt anything about this before.So it is kind of confusing to me. But after many time i done the question, it increase the understanding of me about the java.

First, I get to know that "public static void main(String[] args)" is very important. Every single word, upper and lowercase for that sentence is very important. We can't leave any words behind for us to run a success java program.

Besides, we also need to declare every symbol that we gonna to use before we can run the program. If we declare the word in lowercase then it should be in lower case. For the "int" it only declare for integer and no decimal. If we want the answer to be in correct decimal answer, then we should "double" it.

Another problem I realize is we can't really get the answer if the value is too big for certain data type. It can be consider as overflow because every data type had it own range. For example, in Test 6, I can't really get the answer for it as it write that the value is too big and I googling it and realize we can solve it by putting L letter behind the value which the L letter also mean by long.

In Test 8 that I can't get the answer of 0.1, it appears 0.1999998876 something which just a value that is close to 0.1. It will happen because computer is in binary and 0.1 doesn't have a finite representation in decimal. Therefore, I try to control the decimal point by import the DecimalFormat which I had learnt in computational physics.

In Test 9, that actually is a run-time error occurs since it is divide by integer 0.

Next link: Oh Hui Min

No comments:

Post a Comment

Lab 1

This is the second lab for this course and it become complication since I never learnt anything about this before.So it is kind of confusing...