Sunday, January 22, 2012
Codelab Catchup
I got confused between the lab portion on my CS class and the online CodeLab part (online homework assignments). I've been going to lab, but forgot to do the online assignments. Today I went online and did all of the assignments I had missed and almost all of the ones that are due next week. After programming for about two hours I felt I learned a lot.
Some problems I ran into were:
-integer division: one problem asked to create a program that converted Fahrenheit to Celsius then report it using the printf function (I think it's called a function, not sure...). This seemed simple enough, so I wrote it out, but whenever the answer printed out it appeared to be 0.00. The spacing and digits after the decimal were correct since I had some experience with printf in MatLab. I spent about a half hour looking over the 10 lines of code trying to find the error. After double checking that I used the correct conversion equation from degF to degC and milling over the printf statement, I decided to look in the textbook. To my relief the exact program was in the textbook and I instantly realized why it wasn't working the way I wanted it to. I was using 5/9 instead of 5.0/9 in the F to C conversion equation. Since Java is picky, it truncated the result of 5/9 to 0 because it used integer division, when I wanted the result to be a double. Now I know better!
-remembering code: not exactly a problem, but since I'm still new at this I don't know exactly the reasons why I type some things (e.g. Scanner input = new Scanner (System.in);) and I have to resort to either copy/paste or try to use purely memory. Hopefully as I learn more I will understand the purpose for words and their order.
-Eclipse: I figured out some of how the directory is laid out. I'm not really sure how to save my work (not that it is that precious yet) but it seems there is a file structure in place that includes a "Workspace" then "Project" into a "Package" and "Class". There is definitely a workflow structure but I don't know the purpose of anything yet. When Codelab asked me to submit multiple programs with the class as P3 I couldn't save them within the same package. This makes sense and is the same file system that computers have, but when I tried to make a new package (instead of using the default, which Eclipse recommended I do) and put a class called P3 in it, the Codelab didn't like that.
-variables: I'm not sure how to allow an input to make an arbitrary number of doubles without previously creating the variables and filling them with values that are entered (which would limit the amount of variables that can be input to the number that were already in the program). My friend just told me that I need to make an array in order to do this, but neither him nor I know how to do this in Java. Alas...
Anyway I have plenty to learn, but I'm learning at an alarming rate which is nice.
AWESOME!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment