<?xml version="1.0" encoding="iso-8859-1"?><rss version="1.0"><channel><title>Diary of Sasikumar M</title><link>http://thelittlesasi.rediffiland.com/</link><description>Diary of Sasikumar M</description><language>en-us</language><item><title>Initiative for research and innovation in science</title><description><![CDATA[<BR>I was a judge for the national IRIS fair this year in Pune. It is a joint initiative between CII, DST (GoI) and Intel, and continuing for<br>many years now. I have been associated with it in one way or other for<br>4-5 years now, but the first time I am going as a judge in the national<br>fair. There were about 15 of us in the Judges category covering various<br>subjects ranging from computer science and environmental science to<br>maths and physics. The participants are either class 5 to 7 students or<br>class 8 to 12 students. There is a fairly rigorous process to enter,<br>starting from submission of synposis, its screening, feedback,<br>mentoring, etc. There are subject category prizes and special mention<br>prizes, and the main prize of representing India in the international<br>version of the fair, this time in Atlanta. I think, Intel bears all the<br>expenses for the trip for the child and a guardian.<br><br>It is interesting to see the enthu among the kids. There is a lot of grooming<br>- so most of them talk polished English, well rehearsed. Unfortunately,<br>there is too much pressure being applied on the system, with parents<br>and guides desperate to win the prize at any cost. So, cut and paste<br>from the net is not uncommon - and it takes away a good part of the<br>judging time to eliminate them from the short list. Guides/parents<br>doing bulk of the work is also not very rare.<br><br>It is unfortunate that these events are not reaching the vast number of schools in India. No institution can spend<br>enough money to enhance the outreach beyond a<br>point. We need more ambassadors of this program at every nook and<br>corner. Interesting and brilliant ideas do come from all of these<br>places. The Metro culture tend to think in an imitating style, bringing<br>in more of the same type of projects. For example, every year, there is<br>a class of extraction projects. Take some natural substance say X<br>(plants, paper (wasted), weeds, fruit peels, etc) and extract some<br>useful chemical Y from it (mosquito repellent, cockroach control,<br>thermocol, plastic, various chemical compounds, etc). You will see them<br>in various X-Y combinations. Energy is another popular topic with<br>various innovations in exploiting solar power (as electricity, heat,<br>etc) and wind power. There was even a project which gathers the heat<br>generated by the burning coconuts in Sabarimala temple and produce<br>electricity from that.<br><br>At times due to the pressure factor,<br>there is a tendency to defend things without knowing - something that<br>gets me irritated often! And lack of adequate mentoring is also often<br>seen - resulting in a lot of effort being put in, but not reaching any<br>useful results. If someone could get these kids to think further, probe<br>further, etc by asking them the right questions, they would go far. I<br>found this in many cases - if you point out a flaw in their work, they<br>are open to think over and suggest, often sensible, solutions. We need<br>to do this more often...<br><br>On the whole a nice experience.... The<br>enthu on the students" faces is nice to see, coupled with the innocence<br>of their age. Wonder how many of them will retain! This year the theme<br>was the power of "Q" - questioning. "Einstein had the power of Q" - say<br>posters in the halls. Of course, they also had big banners on all<br>vehicles and roads declaring "geniuses inside - drive carefully" or<br>"geniuses on the move" -� I thought this was going far. We should<br>reward, recognise and encourage - but in a limit appropriate to the<br>nature of achievement. Overdoing it will create negative impact.<br><br><br><BR>]]></description><pubDate>Sun, 09 Dec 2007 13:29:42 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/12/09/Initiative-for-research-and-innovation-in.html</link></item><item><title>Notion of a Block</title><description><![CDATA[This seems to be an appropriate time to introduce anorganisational construct which is integral to today's<br>programming languages - the notion of a block. We will<br>start with introducing a simple view of a block and<br>expand it gradually later on.<br><br>As you may have observed, our programs are getting larger<br>in the sense of number of statements and more complex.<br>When you write long documents, you dont string every<br>sentence one after another in a series in a flat list;<br>we gather sentences into paragraphs, paragraphs into<br>subsections, subsections into sections, sections into<br>chapters, and so on. This helps us to comprehend the<br>structure of a document relatively easily. Imagine figuring<br>out where is something if a 200 page book was just one<br>paragraph. A block in a program is like a paragraph.<br><br>Normally a paragraph denotes one idea. Though there are<br>no laws in this regard, it is the recommended practice.<br>Good documents follow this. Similarly, what you put in<br>a block must be related set of statements. Neither the<br>programming language, nor the compiler would do anything<br>to enforce this. But programs that dont follow this tend<br>to be nightmares for those who need to deal with it later<br>on - including the developer who wrote it!<br><br>More than convenience, there are situations where such<br>grouping is necessary. Let us look back at our if-statement.<br>Suppose, there are more than one action to do when the<br>condition is true/false. For example, if k &gt; 10, then<br>set i and j to 1. We may write this as:<br><br>    if (k &gt; 10)<br>       i = 1;<br>       j = 1;<br><br>This actually won't work, because this does not indicate<br>that j = 1 is to be done when i = 1 is done, and not otherwise.<br>The system assumes that i = 1 is to be done when (k &gt; 10) is<br>true. But j = 1 is assumed to be a statement following the<br>if-statement.<br><br>In other words, the 'then' part of the if-statement is<br>assumed to be a single statement. To put multiple statements there,<br>we need a grouping device. A block is best suited for this.<br><br>What does a block look like? It is a collection of statements,<br>surrounded by a start and end indicator. Java uses '{' and '}'<br>as the block start and end indicators. So,<br><br><br>  { i = 1;<br>    j = 1;<br>  }<br><br>is a block. In general, in Java, as well as in most languages, a<br>block is allowed wherever a single statement is allowed. So, our<br>if-statement should be written as:<br><br>    if (k &gt; 10)<br>       { i = 1;<br>         j = 1;<br>       }<br><br>The choice of where to put the braces is left to you. Choose a<br>convenient convention, and use it consistently. Readability, space<br>usage, etc are some of the considerations in choosing a convention.<br>Here are some common variants, in the case of an if-statement:<br><br> if (k &gt; 10) {<br>       i = 1;<br>       j = 1;<br> }<br><br> if (k &gt; 10)<br> {     i = 1;<br>       j = 1;<br> }<br><br> if (k &gt; 10)<br>     {<br>       i = 1;<br>       j = 1;<br>     }<br><br>Coming back to our if-statement, with the block structure, the statement<br>does what we wanted it to do. See the two code segments together and<br>understand the difference.<br><br> if (k &gt; 10) {                if (k &gt; 10)<br>       i = 1;                     i = 1;<br>       j = 1;                     j = 1;<br> }<br><br>There is more to block structure, that we will see later.<br><br><BR><BR>]]></description><pubDate>Sat, 01 Dec 2007 11:42:04 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/12/01/Notion-of-a.html</link></item><item><title>PP: More on Conditionals (incl Switch)</title><description><![CDATA[<BR>In the previous post, we saw the basic nature of conditionals in programming languages. Some way to handle conditional is essential in any programming language. And most of the languages represent them as some variant of if-then-else. Some languages abbreviate "else if" as "elif", etc as another convenience. Note that these are just decorations, and does not add any power or flexibility to languages.Compare the sequences (A):<br><br>if c1 then a1<br>if c2 then a2<br><br>and (B):<br><br>if c1 then a1<br>else if c2 then a2<br><br>These are not equivalent. This is a common mistake most beginners make. The equivalent version of (B), without using "else" is:<br><br>if c1 then a1<br>if not c1 and c2 then a2<br><br>Similarly, when there is a series of "else if"s, the last else actually corresponds to "(not c1) and (not c2) and (not c3)...".<br><br>A special case of these conditionals often occurs in programming, for which most languages have introduced a special construct: the <span style="font-weight: bold;">switch</span> statement.<br><br>One of the clauses in the income tax law states: <span style="font-style: italic;">a standard deduction of 10000 Rupees is allowed on the income, for males and 15000 for females.</span> So, after you compute the total income, you need to deduct this amount before computing tax. You can write:<br><br>if (sex is male) then sded = 10000<br>else if (sex is female) then sded = 15000<br><br>Let me take a moment"s diversion here. Take a closer look at this statement, and in particular, the second if-condition.<br><br>Assuming that sex is either male or female, one does not need the second condition check. The else indicates that sex is not male, and hence it must be female. However, in general, it is useful to put that condition there. One purpose is clarity. It makes the law very explicit. This is very handy, when you update these statements when the rules change next year, where these categories may be revised.<br><br>However, when you include this condition, semantically the statement is incomplete. What if both conditions are false? What happens to standard deduction? But, can both conditions become false? In computer programming parlance, it is possible. Someone when entering data, may have entered a wrong value for "sex". It could be a mistake in typing, or filling in some other column value for this column in the form, and so on. So, it is a good idea to address these by extending the statement as:<br><br>if (sex is male) then sded = 10000<br>else if (sex is female) then sded = 15000<br>else print "illegal sex value"<br><br>Such small precautions can save you days of effort in tracking down bugs. Without this, it is possible, you will happily go ahead calculating sded, using an illegal value and get, say, the total tax wrong. And you will wonder what went wrong. Alert messages as given above, get you to the root of the problem much faster and with less pain.<br><br>Coming back to the notion of switch statement, this kind of branching depending on the different values of a variable is what a switch statement facilitates. Another example:<br><br>print "choose your language: 1 - English, 2-Hindi, 3-Tamil, ..".<br><br>You can see such directions in ATM machines, telephone answering services. You need to choose one out of a set of options provided. (We will see later how to read a user's choice - for now, let us assume we know). And you have to perform different actions depending on the choice made. Unlike in the tax computation example, here the choice is dependent on different values of a single variable as in:<br><br>if (lang == 'E') then ....<br>else if (lang == 'H') then ....<br>else if (lang == 'T' ) then ....<br><br>Or<br><br>if (option == 1) then ....<br>else if (option == 2) then ....<br>else if  (option == 3) then ...<br><br>A switch statement provides a short hand for these kinds of code segments:<br><br>switch (option) {<br>  case 1: .....; break;<br>  case 2: .....; break;<br>  case 3: ....; break;<br>  default: print "illegal option";<br>}<br><br>Against switch you specify the variable on which you want to branch on, and against 'case', you specify the possible values. In place marked '.....', insert the code corresponding to different values.<br><br>Compare this template with the if-then-else template given before, and you can see the mapping. In principle, you can convert any switch statement to  if-then structure (of course, not vice versa!). <br><br>In the template you see two new entities: break and default. Let us try to understand why they are there and what they do.<br><br>The 'default' is like the catch-error else part we had introduced in if-then earlier. A way to specify some action, in the event of the value not matching with any of the listed values. So you can write our sex-tax code as:<br><br>switch (sex) {<br>  case 'M': sded = 10000; break;<br>  case 'F' : sded = 15000; break;<br>  default : sded = 0; print "illegal sex value";<br>}<br><br>The value not matching can arise in two cases. One is the error condition, we have sketched here. Another is a scenario like this:<br><br>switch (sex) {<br><BR>  case 'F' : sded = 15000; break;<br><BR>  default : sded = 10000;<br><BR>}<br><br>This captures the rule 'for females, the exception is 15000; for everyone else it is 10000''. This is same as the above, if we are sure that the only sex values are 'm' and 'f'. Thus, you can use 'default' to pull together all values that need not be given special attention.<br><br>What is the 'break' about? 'Break' is a general construct - not specific to switch - with the meaning 'break free'. We will discuss this in a later post. For now, just make sure to put a 'break' after handling each possible value in a switch.<br><br>Practice writing in if-then-else form and switch form, the various conditionals that you can think of. Write them in as many different ways as possible, and see how they differ in readability, efficiency, correctness, etc.<br><BR>]]></description><pubDate>Sun, 25 Nov 2007 15:03:24 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/25/PP-More-on-Conditionals-incl.html</link></item><item><title>PP: Conditionals</title><description><![CDATA[<BR>What we saw in the last blog was a simple tax calculator - perhaps too simple to be useful. We made a lot of assumptions to ensure that we can complete the program, with constructs we know. One major assumption was the flat tax rate. Typical tax rate specification would be something like this:Income upto Rs A : no tax<br>Income over A but less than B: 30% of income<br>Income over B but less than C: 30% of B + 50% of (Income - B)<br>Income over C : 30% of B + 50% of (C-B) + 70% of (Income - C)<br><br>The number of slabs may vary, but you see that the computation depends on which income slab your income falls in. So, you want to write your program as:<br><br>if income less than A then tax = 0<br>if income greater than A and less than B then tax = income * 30/100<br>if income greater than B and less than C then tax = B * 30/100 + (income - B) * 50/100<br>and so on<br><br>This is where conditionals are useful. A construct which allows you to do something only when a specific condition is true, is a necessary part of any programming language. In Java, the conditional construct looks like the informal notation above. More formally, we would write the same in Java as:<br><br>if (total_income &lt; 100000) income_tax = 0;<br>if ((total_income &gt; 100000) &amp;&amp;� (total_income &lt; 200000)) <br>�� income_tax = total_income * 30/100;<br><span style="font-style: italic;">and so on.<br><br></span>Despite the remarkable similarity with the English notation, note some important differences.<br><br>"then" word is not used to indicate the action to be performed. This is the case in many of the programming languages, though some languages do mandate it to be used. One problem when you omit "then" is the difficulty in identifying the end of the condition and the beginning of the action part. Therefore, it is customary to expect that the entire condition part be enclosed in brackets as shown in the example above.<br><br>Secondly instead of English terms like less than, we use symbols for them. The standard set of symbols for common conditions are as follows. This set is also followed quite the same way in most languages.<br><br>less than &lt;������� less than or equal to� &lt;=<br>greater than &gt;�� greater than or equal to &gt;=<br>equal to ==���� not equal to &lt;&gt;<br><br>Of particular importance is to note the symbol for "equal to". Remember the symbol used to assign a value to a variable. We used "=" to denote that. In order to avoid confusion with this, a comparison check between two values is denoted with two consecutive equal signs. Common mistakes in programming is to interchange these two symbols. Some of these may be detected when the compiler compiles the program; but not all such cases can be reliably detected. So be careful with these symbols.<br><br>Also note that "&gt;=" and "=&lt;" are not equivalent. While languages differ on what is the symbol for 'greater or equal', they will allow only one of these for this purpose. Often, the other symbol may be used for some other purpose. For example, '=&gt;" is often used as an arrow or as implication operator, and hence has nothing to do with "&gt;=".<br><br>As in the case of comparisons, we use specific symbols for logical operators. &amp;&amp; for 'and', || for or, ! for not, etc. Again, the English terms are not acceptable. Single &amp; and single | are used for other purposes (we will see later), and hence the use of symbol-pairs here. [order of evaluation of conditional: tbd].<br><br>If we look at our daily usage, we use conditionals in two distinct ways. One is to do something only if a condition is true. If it is likely to rain, take an umbrella. If the condition is false, nothing is to be done. The second case is where we use a condition to choose between two alternatives. If your score is less than 45, your status is fail, otherwise your status is pass. There is something to be done irrespective of the condition being true. For this case, it would be useful to have an 'otherwise' construct. And most languages provide you an 'else' companion to the 'if' statement.<br><br>if (condition) do-something<br>else do-something-else<br><br>Look at this for a minute. Strictly speaking, you dont need this. You can always write this as:<br><br>if (condition) do-something<br>if (not condition) do-something-else<br><br>In some cases, the former is more intuitive. It also means the condition will be evaluated only once. So, when there is a choice, use if-then-else. Otherwise, use if-then.<br><br>And you can extend this further. What if we have a choice between three options, as in our tax computation case. We had three or four slabs, and we need a different tax formula for each of them. We can nest the if-else structure.<br><br>if (income &lt; A) something<br>else if (income &lt; B) something-else<br>else if (income &lt; C) something-different<br>else error<br><br>.....<br><br><span style="font-style: italic;"></span> <br><br><BR>]]></description><pubDate>Tue, 13 Nov 2007 18:55:35 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/13/PP-.html</link></item><item><title>PP: Tax Exercise</title><description><![CDATA[<BR>So, we can now start writing some useful programs. Let us take some practical application. We want to compute the income tax payable by a salaried employee. For now, let us make some assumptions, so that the world fits in what little we know of programming.For computing tax, we need to compute the total income first. For salaried employees, the core element of income is one"s basic pay. Using the concept of variables, let us define this as a variable, since we may need to change this for different persons, and we may want to use this figure for computing various other aspects of his income and tax. So,<br><br>�� basic_pay = 8000<br><br>This is monthly basic pay. For tax purpose, we need annual figures. So:<br><br>� annual_basic = basic_pay * 12<br><br>You can see that we dont write 8000*12, but basic_pay * 12. So, when we change the basic pay, the computation of annual_basic will not become wrong.<br><br>Another major component of income is the "dearness allowance", generally called DA. DA is a percentage of basic. This percentage will vary from time to time, based on some government notification. So, it is useful to make this explicit, to allow easy change.<br><br>� DA_percentage = 83<br><br>Now the DA can be computed.<br><br>� annual_DA = basic_pay * 12 * DA_percentage/100.<br><br>In a similar way, we can define house rent allowance (HRA).<br><br>� annual_HRA = basic_pay * 12 * 30/100<br><br>HRA is 30% of the basic; not something that changes often, and hence we have opted to keep it a part of the ex-pression. Let us assume there is no other income. So, we have the total income.<br><br>�total_income = annual_basic + annual_DA + annual_HRA<br><br>In the simple case, the tax is a simple fraction of the income, say 20%. So, tax is:<br><br>� income_tax� = total_income * 0.20<br><br>Note that 0.20 is 20/100 - we can write it either way. In one case, we make the computer do this computation; in the other, we do it ourselves. Here, the difference is not important for two reasons. First the ex-pression is so simple, the cost of computation is low for us and also for the computer. So, it perhaps does not matter, who computes it. Second, both the forms are adequately intuitive - so there is no loss of readability. Whenever, you have a choice of such a decision, apply both these criteria. For example, if you have to multiple something with PI/7, it is better to write it as pi/7, instead of 0.448. The latter form is not intuitive and a reader will wonder what this number is! Even you may not remember after a while. So, it is generally a good idea to give most of these 'magic numbers', a relevant name and use a variable of that name in your program.<br><br>Now, here is the consolidated program, which you can replace 'YOUR PROGRAM' in our template with. We have added the relevant declarations for the variables we have introduced.<br><br>int basic_pay, annual_basic;<br>float DA_percentage, annual_DA, annual_HRA;<br><font><font class="f12" color="#000000">float total_income;<br>basic_pay = 8000;<br></font></font><font><font class="f12" color="#000000">DA_percentage = 83;<br></font></font><font><font class="f12" color="#000000">annual_basic = basic_pay * 12;<br>annual_DA = basic_pay * 12 * DA_percentage/100;<br>annual_HRA = basic_pay * 12 * 30/100;<br>total_income = annual_basic + annual_DA + annual_HRA<br>income_tax� = total_income * 0.20<br></font></font>System.out.print("Total income is "); System.out.println(total_income);<br>System.out.print("Tax payable is "); System.out.println(income_tax);<br><br><br><BR>Try it out with different basic_pay and other parameters. Can you modify this program by adding Rs 800 as a fixed conveyance allowance per month, and Rs 10000 as an annual allowance.<br><br>We will follow this example in the next section to introduce conditionals.<br>]]></description><pubDate>Mon, 12 Nov 2007 13:59:49 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/12/PP-Tax.html</link></item><item><title>PP: Calculator</title><description><![CDATA[The name 'computer' means something that can compute, usually refering to numerical computations. One simple application of this is demonstrated by a normal desk calculator. You can use it to make arithmetic calculations, 30*0.6, (100+3)/4, etc. You can, thus,use it to compute total expense for a project, monthly installment, total saving in a day, and so on.<br>It is easy to use any programming language as a rudimentary calculator. Remember the System.out.print instruction we saw earlier. We, there, gave it a string to print - a piece of text. We can put in any expression to print.<br><br>Consider the problem of computing service tax on a set of items purchased from the shop. You know the rate of service tax is 2.4% (hypothetical), and the tax is computed by finding the total amount payable and taking its 2.4%. Assume we bought 5 items costing 10, 15, 20, 50 and 60 Rs. So the tax would be = (10+15+20+50+60) * 0.024. We can turn this into a Java program quite easily:<br><br> System.out.println((10+15+20+50+60) * 0.024);<br><br>Note that there is no quote marks around what is to be printed. Try the same with quotes:<br><br>System.out.println("(10+15+20+50+60) * 0.024");<br><br>Instead of the tax, you get the same expression back. That is because, the quote told the system to treat the expression as a string - as a sequence of characters. It did not interpret them as an expression.<br><br>For this reason, numbers are treated differently by all languages - the difference between "2" and 2. The former is a string and the latter is a number. You can do 2+3 to add two numbers to get 5, but you will not get<br>5 from "2"+"3". [This summation actually produces "23", since the plus sign is interpreted as concatenation operator - more on this later].<br><br>The print instruction can take a number, apart from a string. The number can be a direct number as in: System.out.println(3), or a result of an expression.<br><br>So, System.out.println((10+15+20+50+60) * 0.024), does indeed produce the tax amount.<br><br>Try different expressions and see if everything works fine. You can use, + for addition, - for subtraction, * for multiplication and / for division.<br><br>It is possible that the tax calculation may need to be done multiple times in the program. It is also possible that the tax rate may change from place to place, and time to time. Modifying the program by changing the number everywhere is an error prone task, and too time consuming. Remember that all occurences of 0.024 may not be referring to service task percentage, and there is no way to distinguish?<br><br>Yes, there is a way. We can give names to these numbers, using <span style="color: rgb(255, 0, 0);">variables</span>. These can be visualised as named containers. Instead of the number 0.024, we can say, 'the content of service_tax container'. We need to define these containers, assign contents and use them. Since we are now dealing with numbers, we define service_tax as a number:<br><br>   float service_tax;<br><br>floats are decimal pointers, those with an explicit decimal point. There is another kind of numbers - integers, what we call whole numbers. 1, 2, 20, 120, etc are integers. 1.3, 5.6, 10002.2, etc are floats. We can define another container named 'n_items' to denote number of items purchased. This would be an integer container and will be defined as:<br><br>  int n_items;<br><br>int is short for integer (Java has something called 'Integer' - we will see that later on).<br><br>You assign values to a container by an <span style="color: rgb(255, 0, 0);">assignment statement</span>. We will need:<br><br>  service_tax = 0.024;<br><br>The right side can be any number or an expression which evaluates to a number. If we are used to seeing the service tax as a percentage, we can write the same as:<br><br> service_tax = 2.4/100;<br><br>Now, we can modify the print statement as:<br><br>  System.out.println((10+20+25+50+60)* service_tax);<br><br>This produces the same output. Check it out. If you get any error, you may have typed the variable name incorrectly somewhere. Make sure that your definition, assignment and use has exactly the same name.<br><br>Now, if the service_tax need to be changed, you can just change the line assigning 0.024 to whatever is appropriate, and the change will be consistently applied throughout your program.<br><br>What if you want the service tax on each item individually? You can write:<br><br>System.out.println(10 * service_tax);<br>System.out.println(20 * service_tax);<br>System.out.println(25 * service_tax);<br>System.out.println(50 * service_tax);<br>System.out.println(60 * service_tax);<br><br>So, with variables, you can re-use an item any number of times.<br><br>Use of variables is a major aspect of programming - though it appears to be a very simple concept. As we will see later on, things are not that simple as we make our requirements more and more complex. Keep your questions ready...<br><br><span style="text-decoration: underline;">Exercise:</span><br>Print the annual interest on various deposit amounts, 1380, 49850, 40000, etc at an interest rate of 9%.<br>Print the annual interest on an amount of 14300 at various interest rates of 7.5%, 8%, 9% and 10.3%.<br>Which numbers are worth being assigned to variables, and why?<br><BR><BR>]]></description><pubDate>Sat, 10 Nov 2007 14:16:03 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/10/PP-.html</link></item><item><title>PP: Hello</title><description><![CDATA[From the days of the famous book on C language by Kernighan and Ritchie, it is customary in teaching a programming language to start with a hello to the world. It is also perhaps the simplest program to write, so we will not violate this tradition.<br>To produce some output from your program, you use the notation<br><br> System.out.println("Hello, world!");<br><br>Type everything including the dots as it is. You can recognise the "print" word there reminding you that it is going to print something on your screen. The "ln" following indicates that the next output will start on a fresh line.<br><br>Replace the "YOUR PROGRAM" in the template with the above line, and try compiling and running the program. The program will look like:<br><br><font class="f12" color="#000000"><span style="font-family: Courier New,Courier,mono;">public </span><span style="font-family: Courier New,Courier,mono;">class Myclass </span><span style="font-family: Courier New,Courier,mono;">{</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">    public static void main (String arg[]) {</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">         System.out.println("Hello, World!");</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">    }</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">}</span></font><br><br>Instead of "Hello, World!", you can put any text inside. Text enclosed in double quotation marks is called a <span style="color: rgb(255, 0, 0);">String</span> in Java. Do not use text containing quotation marks - they need a little special treatment. So, dont try: "Should I try " in the string"<br><br>Try, "Welcome, World" and other variants. Only simple text.<br><br>As I mentioned above, the 'ln' indicates that the next output on the screen will start on a new line. Let us try this: <br><br>    System.out.println("Hello, ");<br>    System.out.println("World!");<br><br>You will see that "Hello" and "World" are coming on two different lines. Try this now:<br><br>    System.out.print("Hello, ");<br><BR>    System.out.println("World!");<br><br>Note that the first line is now just "print", and not "println". This tells the system not to move to the next line. This code will produce "Hello, World!" in one line.<br><br>That is our first little program....<br>]]></description><pubDate>Sat, 10 Nov 2007 12:30:54 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/10/PP--1.html</link></item><item><title>PP: Building the background</title><description><![CDATA[<BR>We begin our journey here. We will spend a few minutes getting ready - setting up our rules and norms for the journey, making sure we have the needed resources, and the like.<br>First of all, this is a course on programming. It is like swimming - no amount of reading will make you good at swimming. You need to swim. You may not succeed at first. You may sink into the water, may drink a lot of water - much beyond your liking - it is all part of the learning process. But dont drawn - that is where systematic learning comes in. It is foolish to jump into deep sea, and try to learn swimming. It is foolish to go and practice with no security devices (floating devices, the guards on duty, etc). The lessons and specific targets play that role - so that you dont get hurt too much. Given that, dont be afraid to try. You will develop confidence - you will know what works well for you and what does not. You will know where your weakness is and where your strengths. Slowly you can build your own style of swimming (read, programming).<br><br>So, it is important you have a programming environment to practice. In the beginning I would suggest not using any development environment. The programs will be really simple, and an IDE will hide important details. As we go further, you can try them. For now, just make sure you have a simple text editor (the classic vi, notepad, and so on). Do not use word processors - they do not store the files in plain text format. They have to store formatting and the like, and hence makes it impossible for the compiler to read your program. So, ensure you have a simple plain text editor. And ensure you have Java installed. You can download and install it from java.sun.com. It will give you two commands: javac and java.<br><br>javac is the command which turns our Java programs into a format that the Java interpreter understands. For now, dont worry too much about what this means. And the command java executes your program. You provide inputs and receive outputs, at this stage.<br><br>So,<br><ul><li>You write a program using the text editor. Let us say, the file is called pgm1.java; note that the extension is important. You can name the file in anyway you like. You can name them based on the chapter in which the program is described, or based on the nature of the program. Eventually, you should it more along the latter lines. Eg. chap1ex1.java (first exercise in first chapter), hello.java (program to print hello), etc.</li><li>Then you compile the program using javac. "javac pgm1.java". This will create a file called pgm1.class in your directory. Watch for any errors, etc. As a practice, make sure no warning is left. Even though some warnings may appear harmless, fix them. It is a good practice - like stopping swimming, when you notice mild discomfort. It prevents major problems later on.</li><li>And then you can run the program with "java pgm1" - it will run the compiled .class file.</li></ul>For every exercise, do all these, and ensure you test out your program well that it works for a number of different inputs. Dont stop with one input. Programs can surprise you - working well for 99 inputs and failing on the 100th. We will later see such errors.<br><br>The second part of the preparation is to prepare some skeleton for us to start. For, even the simplest Java program to work, we need a few lines of code. Whenever you write a program (we will withdraw this restriction, later on), include this in your .java file exactly as it is. And your program will be written in the part marked "YOUR PROGRAM". Some examples in next chapter will make this convention clear. The significance of this skeleton part will become clear as we go along. For now, just trust me and come along.<br><br>�<span style="font-family: Courier New,Courier,mono;">public </span><span style="font-family: Courier New,Courier,mono;">class <span style="font-style: italic;">Myclass</span> </span><span style="font-family: Courier New,Courier,mono;">{</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">�� public static void main (String arg[]) {</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">����� YOUR PROGRAM </span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">�� }</span><br style="font-family: Courier New,Courier,mono;"><span style="font-family: Courier New,Courier,mono;">}</span><br><br>The name "Myclass" should be replaced with the name of the file you are going to save the program in.<br><br>We are now set to write our journey.<br><br><br><BR>]]></description><pubDate>Sat, 10 Nov 2007 11:45:09 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/10/PP-Building-the.html</link></item><item><title>Programming Progressively....</title><description><![CDATA[<BR>With this post, I am starting a little journey making an attempt to teach programming. Quite too often, programming is taught from the language point of view - showing the data types, the control structures, the libraries, etc. Here, we will take a different approach - or rather we will try to!I dont know how much my enthu will last for this adventure. It will also depend on how people (you, the readers/friends) react to this. Feel free to comment on the posts, I will try to absorb them into the writing as I go along.<br><br>I will use Java as the programming language. But I dont think, my approach and content will depend too much on the language. The attempt is not to make you a master of Java (or whatever language); but rather to make you understand programming. Introducing constructs, as we need them. Showing how the constructs help you solve problems.<br><br>Ready? Fasten your seat belt and come along....<br><br>Index to posts on this thread:<br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1194675309" target="_self">Preparing background</a><br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1194678054" target="_self">Hello World</a><br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1194684363" target="_self">Calculator</a><br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1194856189" target="_self">Tax exercise</a><br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1194960335" target="_self">Conditionals</a><br><a href="http://thelittlesasi.rediffiland.com/scripts/xanadu_diary_view.php?postId=1195983204" target="_self">More on conditionals (incl switch)</a><br><br><br><br><br><BR>]]></description><pubDate>Sat, 10 Nov 2007 11:39:33 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/11/10/Programming.html</link></item><item><title>e-learning</title><description><![CDATA[<BR><ul><li><font size="5"><span style="font-family: Times New Roman,Times,serif;"><font size="3">Teatrix: virtual environment for story creation, R Prada, Machado I, Paiva A. ITS-2000</font></span></font></li><li><font size="5"><span style="font-family: Times New Roman,Times,serif;"><font size="3">PUPPET: a virtual environment for children to act and direct interactive narratives. Marshall P, Rogers Y, Scaife M. 2nd International workshop on narrative and interactive learning environments, 2002</font></span></font></li><li><font size="5"><span style="font-family: Times New Roman,Times,serif;"><font size="3">Review of E-learning theories, frameworks and models. T Mayers and S de Freitas. http://www.htk.tlu.ee/icamp/articles/elearningmodels.pdf/view</font></span></font></li></ul>Interesting threadsPLEs - personal and personalised learning environments [anyone has some good online reading material on this?]<br><br><font size="5"><span style="font-family: Times New Roman,Times,serif;"><font size="3"><br></font></span></font><br><br><BR>]]></description><pubDate>Wed, 17 Oct 2007 10:04:27 +0530</pubDate><link>http://thelittlesasi.rediffiland.com/blogs/2007/10/17/e-learning.html</link></item></channel></rss>