Monday, March 11, 2013

Cycle 3

Welcome to Cycle 3!

I have totally immersed myself into the world of Java and its object oriented greatness during this third cycle. The journey has been interesting, with me discovering new, hidden secrets about Java every day. This week, I went more into depth with the fundamentals of the Java programming language and then started to follow some instructions in my Java For Dummies book to make some basic data manipulation programs. So, fasten your seat belts, because you're in for a wild ride!

First, let me explain fundamentals i more detail. I'll build on what I covered last cycle. Some new fundamentals I learned about were different types, like "char," "double," and "boolean." I also learned about how to manipulate variables in my programs.

Types in Java allow us to describe certain variables to the computer. A variable, as the name suggests, is an object or numeral that varies depending on a certain input. In mathematics, we name variables as letters, like a, x, and n. In Java, variables can be named anything that "floats your boat." If there was a program that told people how many people could fit in an elevator, I could name the variable that examines how many people get onto the elevator "numberOfPeople," or "pie," or "peopleThatBoardElevatorsDefinitelyLoveJava!" It is also worth noting that variables that are multiple words are named without spaces. Also, the first letter is lowercase and the first letters of every other word are capitalized. Now, on to the types. I'll explain three types that are used in Java: the char type, the int type, and the boolean type. The char type is the way Java describes characters that are variables. For example let me show a demonstration:

class HowToUseTheCharType {

public static void main (String args[]) {
char theFirstLetter =  'h' ;
char theSecondLetter = Character.toUppercase (theFirstLetter) ;
System.out.println (theSecondLetter) ;
}
}

Okay, so this is a whole program that eventually ends up displaying "H" on the computer screen. This is a way to use the char type. For now, don't worry about what the "Character.toUppercase" means (I bet you can infer!). Concentrate on the formatting of the char variable. When describing a char variable, the value is enclosed in single quote marks. This can be used to store character values in the computer and use them later.

The next type is the int type, which describes variable values that are whole numbers. For example:

int tirePressureRating
int timeToRunCompressor

This would be part of a program that would figure out how much air to put into a car's tires. I haven't put the whole program in here for reasons of simplicity, but this is the basics of the int type. Before telling the computer what the values of the variables are, the computer needs to know if those values are decimals or whole numbers. By writing "int tirePressureRating" the computer figures out that the tire pressure of a car has to be  a whole number. This type is useful in situations where whole numbers are required or to use less processing power from the computer.

Finally, let's talk about the boolean type. The boolean type is used to evaluate true/false statements. For example:

int tirePressureRating
int timeToRunCompressor
int actualTirePressure

boolean actualTirePressure = tirePressureRating ;
System.out.println ("Your tires are ready to roll!")

Let us now analyze this piece of a program. The int variables are there to show that all of them are whole numbers. In the next statement, the boolean type is used to run a command on the screen; in this case, to display  "Your tires are ready to roll!" The boolean in this case needs to be evaluated as true for the display of the exclamation. If it is false, another part of the program would tell the computer to continue filling the car's tires. This is very useful in true/false situations, where precise quantities need to be measured in order to evaluate the statement.

These types will hopefully be helping me next week when I start to make more basic programs. I also plan to learn about the strategies for writing programs concisely next week. That'll help me make code that is easy to understand.

Just a quick side note: In my IDE, or developing environment, I am learning how to use new tools and functions that will help me jin my quest for programming. Refer to Cycle 1 for more information about IDE's.

See you back next cycle!




No comments:

Post a Comment