Using The cs1 Package

For this demonstration you will need the cs1 package.
You can get that from:
http://www.cs.bilkent.edu.tr/~david/cs101/RevisedCS1Package/cs1.jar
Big big thanks for the creators of this great package.
With the keyboard package, we can take data entered from the user.
import cs1.Keyboard //This imports the Keyboard class from
//the cs1 package.
public class UserVariables undefined
This class file is pretty straight forward. We declared 2 ints, 1 double, and 1 String. Strings are new to us. Strings hold letters and numbers, but they hold numbers differently. You cannot add the numbers together. So you can’t add a string that holds “1″ and “2″ and expect 3. You can add strings to other strings, but they won’t mathematically add.
In the first and second println, we ask for some numbers. The numbers the user types in, will be stored according to their variables. So the first number is stored in num1, and the second into num2. I will explain the Keyboard.readDataType() later.
We can enter a double in our 3rd println, and it is stored into num3.
And on our final println, we can enter a string, which is stored in name. In the last 4 printlns, we are just printing what is stored in each variable.
Now, let’s continue:
Keyboard.readInt();
Keyboard.readDouble();
Keyboard.readString();
Pretty much anytime you see a (.) dot and paranthesis, you are working with a method.
The ‘Keyboard’ part means that you are using a method from the Keyboard class. The ‘readInt()’ is a method inside of the Keyboard class.
(Notice that most class files begin with capital letters and that when naming variables, the first word is usally lowercase, while the remaining have capital first letters.
Ex: myVariableIsLong, thisIsMyHouse, helloYou, etc)
Same thing for double and string.
‘readDouble’ is a method inside of the keyboard class.
‘readString’ is a method inside of the keyboard class.
The difference between these three is that the readInt method only reads integer variables typed from the user. (Otherwise compile error)
The readDouble method only reads doubles, or ints as doubles.
Ex: User types 1, and this becomes 1.0 The readString method only reads String type data. Of course you can enter numbers, but dont expect to mathematically work with them.
That is pretty much the cs1 package in a nutshell.

