Thursday 31 January 2013

Bournvita Quiz


Padmanabhan Krishnamurthy of 8 C and Shuvam Mishra of 7 A secured first place in the Banglore(South) round of the Bournvita Quiz after defeating 53 teams.

Wednesday 30 January 2013

Decision Making - if (I)

  Points to remember:
a.       No semi colon after  the condition in if statement.
Section A
1.       Re write the following using a ternary operator
i.       if(income<100000)                               [ICSE 2007]
tax=0;
else
tax=12;
ii.     if(p>=5500)
k=p*3/100;
else
k=p*10/100;
2.       Re write the statements using if statements:
i.     com=(sale>3000)?sale*2/100:0;
ii.    net =(salary(200000)?salary – (7.33/100)*salary: salary – (5/100)*salary;

3.       What is a block?
4.       Write the differences between if and switch .    [ICSE 2006]
5.       Find the output:
int a=1;
int b=5;
b++;
if(b==5)
System.out.print(“ Value is five”);
else
System.out.print(“ Value is not five”);


Section  B
1.       Write a program to calculate the monthly electricity bill as per the following conditions.
Units                                                 Rate per unit
<=100                                               meter rent
for next 200 units                         Rs.1.00 per unit+rent
for next 200 units                         Rs.1.50 per unit+rent
for >500 units                               Rs.2.25 per unit+rent
Input the consumer name, units consumed.Claculate  and print the bill amount .The meter rent is Rs.200.
2.       A library fine is calculated using the conditions given below:
Days                                                                      Fine
1 to 5                                                          Rs 1.00 per day
6 to 10                                                       Rs.1.50 per day
11 to 15                                                      Rs.2.50 per day
>15                                                            Rs.3.50 per day
3.       A company provides motorbike on rent to its members only.Write a program to input the bike number,name,member id,number of days and calculate the rent to be paid.
Days                                                    Rate per day
first 7 days                                            Rs.500 per day
next 7 days                                           Rs.400 per day
>14 days                                               Rs.200 per day
Print the output in the following format:
Bike No     Customer Name     Member ID    No. of days         Rent to be paid

Time Line

Back to business.................................
Spend half an hour to one hour every day instead of piling up everything on 2 or 3 days.There will be Sec A and B questions on each chapter.The last 3 days for complete tests.If you send me your answers , i would correct and send them back.
Jan 30th                  -----      Decision Making (if)
Jan 31st                   -----      Decision making  (if)
Feb 1st                     -----      Decision Making (switch)
Feb 2nd                   -----      Decision Making (switch)
Feb 3rd                   -----      Loop
Feb 4th                   -----      Loop
Feb 5th                   -----      Loop
Feb 6th                   -----      Methods
Feb 7th                   -----      Methods
Feb 8th                  -----      Mehtods
Feb 9th                  -----      Constructors
Feb 11th                 -----      Constructors
Feb 12th                 -----      Arrays
Feb 13th                 -----      Arrays
Feb 14th                 -----      Arrays
Feb 15th                 -----       Strings
Feb 16th                 -----       Strings
Feb 18th                 -----       Strings
Feb 19th                 -----       Encapsulation
Feb 20th                -----       Data Types
Feb 21st                  -----       Class,Objects
------------------------------------------------------------------------
Feb 22nd                -----        Test 1
Feb 23rd                 -----        Test 2
Feb 25th                 -----         Test 3

Graduation Day

D  Day  27th January ,2013

The choir tuning up before the show.


The School Captain 2012 - 2013 Zubin Nicholas Peraira








Captain 2013 - 2014 designate Paras Belandur

Thursday 24 January 2013

Thanks Giving

On 24th January we celebrated  the traditional Thanksgiving Day at St.Mark's Cathedral in the evening. Our Chaplin Rev.David Rajan was the worship leader and Rev.Moses Jeyakumar delivered an amazing message to our boys asking the Cottonians to show solidarity with the people who are abused and less previledged.He spoke about the Good samaritan.The people who are supposed to help didnt help the man who was hurt  . But the help came from an outsider, an unknown source.The Reverend urged the boys to be the outsider,to help others  no matter which religion ,community , region the victims belong to .  Hope the class of 2013 will keep these in its mind when they leave its alma mater. I liked the special song " Go gently through the years". Please read the lyrics. Wonderful song.
Go Gently through the years,
but go in strength,
Don’t be ashamed of tears,
of anger, or of fears,
For they’re a part of you
And you’re alive.
Chorus
Climb mountains while you may,
 and sing your songs,
Start living every day;
it won’t be long before you turn around
and wonder where life’s gone.
Go firmly through the night,
 but go in peace,
Know for yourself what’s right,
keep all your goals in sight,
For they’re a part of you
and you’re alive.
Repeat chorus
Walk bravely through each day,
and go in pride.
Show that you know the way,
in things you do and say,
For they’re a part of you
and you’re alive.
Repeat chorus



// //
The majestic St.Mark's Cathedral





Psalms



One of my favourite Psalms.


Graduation day quotes


Your families are extremely proud of you. You can't imagine the sense of relief they are experiencing. This would be a most opportune time to ask for money. - Gary Bolding

It is indeed ironic that we spend our school days yearning to graduate and our remaining days waxing nostalgic about our school days. - Isabel Waxman


Graduation is only a concept. In real life every day you graduate. Graduation is a process that goes on until the last day of your life. If you can grasp that, you'll make a difference.
—Arie Pencovici

Tuesday 22 January 2013

Class X - Prep

Hope you all have done the trial exam well. After the Graduation day there will be exactly a month left for your board exam.I dont know how you have planned to use these days for other subjects.But, i feel if you spend half an hour to one hour every day for computers ,it would be easy. Anyway you need a break when you are learning the same subject from morning to night.

I have worked out a schedule keeping in mind the number of chapters we have. I am preparing set of questions from each chapter.I will post everyday.If you are interested ,send me the answers.I will correct and send you the comments.There is no point in reading the questions,you have to write the answers.
I would start posting from 30th onwards.

Please mail me if you have any suggestions.

Monday 21 January 2013

Class X -Data types

Data Types :
  • Primitive data type:
  1. Boolean     -    1 bit
  2. byte            -    8 bits
  3. short          -    16 bits
  4. char           -    16 bits
  5. int              -    32 bits
  6. float           -    32 bits
  7. long           -    64 bits
  8. double       -   64 bits

  • Reference data type : The variable  will represent the  address
  1. Arrays
  2. classes
  3. Interface
Type conversion :
Converting one data type into another data type.
  • Explicit conversion or Type casting
The user can change from one data type to another type. 
double a;
int b;
a=(double)b;
Remember the data type should be whithin the bracket.

  • Implicit type conversion
 It is performed automatically.data will be converted from smaller data type to larger data type.
 The other name for variable is identifier.Literal is the other name for constant.

Escape Sequence :
Represented by a backslash( \ ) followed by one or more characters. Remember to use \ instead of /,coz in the trial exam most of you have used forward slash.

Operators :
This is a very important topic.I am going to skip the simple operators and concentrate more on increment decrement operators. I will post it tomorrow. If you need any topic in detail, let me know.

Basic features of Java

There are some very good questions from this chapter.But almost all of them are direct.
Types of Java :
  • Stand alone : A java program developed by the user.
  • Internet applets : Java programs which are executed using web browser.
Basic features of Java :
  • Object oriented programming
  • both complied and intepreted
  • platform independent
  • No memory pointers like in c++
  • No preprocessor
  • Automatic memory management
  • Built in networking
  • Dynamic binding
  • Open product (i.e) freely available
  • Multithreaded : Perform multiple tasks simultaneously.
 The conversion of high level language(source code) to machine level language can be done in two ways.
Interpreter converts  line by line.
Whereas compiler converts all at once.

Byte code:
The java programs are converted to a code called byte code.It is independent of the machine on which the program is to run.Java virtual machine (JVM)is an interpreter which translates byte code into machine code.
Java Source code--->java complier--->byte code--->JVM

Java code can run on many computers coz  java interpreters(JVM) exist for most operating systems.

Comments in Java :
  • Single line comment : //
  • Multi line comment : /*                        */
Errors :
  • Syntax : e.g semicolon missing,bracket missing,variable not declared.
  • Run time :(e. g)dividing by zero
  • Logic : The program does not produce the answer we want.

Class X - Class and Objects

The questions from this chapter are more or less predictable. No out of the box questions.
Object Oriented Programming :
It is a modular approach.It provides reusability of data.

Object
  • Object is a unique entity whuch contains data and functions (i.e ) characteristica and behaviour.
  • The characteristics in a real world object is considered as the data member in the software object.
  • The behaviour in a real world object is considered as the method or function in sofware object.
Classes :

  • Class is a set of similar objects.Each object has same attributes and behaviour.
  • The charecteristics which make them different are the attributes.
  • Therefore the data members contained within the class are called attributes.
  • A class is the proottype of an object.Each object which belongs to a particular class has data and methods.As class produces objects of similar type, so class is called as an object factory.
Encapsulation :
  • The system of wrapping data and function into a single unit is called as encapsulation.
Data abstraction :
  • It is the act of representing essential features without including background details.
Inheritance :
  • It is the process by which objects of one class can link and share some common properties of objects from another class.
  • The advantage of this property is reusability.
Polymorphism :
  • It is the process of using a function for more than one purpose.


Friday 18 January 2013

Class X - Exception Handling

When we write a program sometimes we cannot be very sure whether it is clean that is error free.The unexpected situation which arises due to the improper use of the code is called as Exception.Overcoming such situation is called Exception Handling.
try and catch are the keywords used in exception handling. Any exception(error) occuring within the try block is trapped. A comment is passed to the exception handler about the error which is done by catch block.

Wrapper Class:

We know that the data accepted through the keyboard will be a string and it should be converted to various premitive data type to do any arithmetical operations.This is done by wrapper class.

e.g:

Integer.parseInt

Package :

A Package is a group of classes which can be imported to a program.

Final Exam

Class 7
  • Ch # 3 : Secondary Storage Devices
  • Ch # 7: Introduction to spreadsheet
  • Ch# 9: Internet ans  e-Mail services
  • Ch # 11 : Fundamentals of HTML
Class 8

  • Ch # 6 : Introduction to HTML
  • Ch # 7 : Elementary HTML I
  • Ch # 8 : Elementary HTML II
  • Ch # 9 : Creating Forms
  •  Ch # 10 : Frames in HTML
  • Ch # 13 : Virus and anti virus
Class 9
  • Ch # 5 : Computing Ethics
  • Ch # 9 : Spreadsheet Basics
  • Ch # 10 : Spreadsheet Functions
  • Ch # 11:Access I
  • Ch # 12: Access II
  • Ch # 13 to Ch # 16 (Java)

Class X-Input / Output

There are different methods of accepting data from the user.
  •  Blue J method
  •  BufferedReader
  •  Scanner
Blue J method has its own limitations.If you want to accept data from the user in between the program, forget it.

Bufferedreader:

The header file for this is import java.io.*;  You have to write this before starting the program. The problem with this method is even you accept a number, it will be considered as string.So you need to convert the string into the other data type.
Supposing you accept  10 and 20, you cannot do any arithmatic operations on them coz both are considered strings.Now, change them to int.
InputStreamReader variable1=new InputStreamReader(System.in);
BufferedReader  variable2=new BufferedReader(variable1);

The bold letters should be in caps.
InputStreamReader i=new InputStreamReader(System.in);
BufferedReader  b=new BufferedReader(i);-------------1
System.out.println("Enter name");
String n=b.readLine();---------------------------------------2
System.out.println("Enter total");
String t=b.readLine();
int tot=Integer.parseInt(t);----------------------------------3

step 1: Use the same variable (i.e) ' i'  here, which is used in the previous line.
step 2: accept the string using the variable  used in step 1.No need to convert to any other data type coz name is anyway string unless the name is 007.Even then it is not his name.
step 3: 't' is a string ,so convert to int.
similarly change string into float ,long double.Make sure you give caps wherever necessary.
 Scanner

import java.util.*; should be included in the first line.
In scanner you dont have to accept as string and convert.Directly you can accept different data types.

Scanner s=new Scanner(System.in);
System.out.println("Enter name");
String n=s.nextLine();----------------------------------1
System.out.println("Enter total");
int t=s.nextInt();----------------------------------------2

step 1 : you can use s.next() also.
step 2 : Instead of int you can accept other data types.

CLass X -Math Functions

The following are the built-in Mathematical functions:
1. Math.sqrt() - finds the square root
2. Math.pow() - finds the power raised to the specified base
3. Mth.min() - finds the smallest of the two numbers
4. Math.max()- finds the biggest of the two numbers
5. Math.abs() - It returns an absolute value.
    Math.abs(5) = 5
    Math.abs(-125) =125
6. Math.round() - If the fractional part is below 0.5 then it returns the same integer otherwise it returns the next integer value.
         System.out.println(Math.round(6.55));   ans is 7
       System.out.println(Math.round(-12.55));  ans is -13

7. Math.floor() - returns the number down to the nearest  integer.
            System.out.println(Math.floor(3.2));              3.0
         System.out.println(Math.floor(3.98));            3.0
         System.out.println(Math.floor(-3.2));           -4.0

         System.out.println(Math.round(-3.98));    -4.0

8. Math.ceil() - Gives next higher integer
       System.out.println(Math.ceil(3.2));                4.0
       System.out.println(Math.ceil(3.98));              4.0
       System.out.println(Math.ceil(-3.2));             -3.0
       System.out.println(Math.ceil(-3.98));          -3.0

9. Math.exp() - gives the exponential value
10. Math.rint() - returns the truncated value of the number after removing the fractional part.
    System.out.println(Math.rint(3.8));                  3.0
11. Math.random() - returns a random number between 0 and 1. 
   To  get the integer random number between 1 and n .
  System.out.println((int)(Math.random()*n));

   NOTE :         

  •  Mathematical functions will give tha answer in double data type.So if you are storing in some variable,make it double.
  • If you are writing the ouput remember to write decimal point and zero.

Tuesday 15 January 2013

Class X Sample Programs

You cannot prepare for the computer application exam just by reading the text book.You should know  the syntax. YOU SHOULD WRITE the programs while preparing for the exam.NO short cuts to success.

For instance, take section B, you midght have noticed one question will be asked from each chapter.So try atleast TWO programs from each chapter.Let me give you some examples, but you have to write yourself.

Let us do programs in if else:
Example 1:
 A library charges a fine for books returned late as given below

first five days                              40 paise per day
six to ten days                             65 paise per day
above ten days                            80 paise per day
Design a program with relevant supporting material to calculate the fine assuming that a book is returned N days late.                                                                              [ICSE 1996]

import java.util.*;
class fine
{
public static void main()
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the number of days");
int d=s.nextInt();-------------------------------------------1
float c;
if(d >=1 && d<=5)------------------------------------------2
  c=d*0.40;---------------------------------------------------3
else if(d>=6 && d<=10)------------------------------------4
  c=5*0.40 + (d-5)*0.65;-----------------------------------5
else
  c=5*0.40 + 5*0.65 +(d-10)*0.80;-----------------------6

System.out.print("Fine="+c);
}
}
step 1 : Accept number of days
step 2: if the days are from 1 to 5 then
step 3: calculate the fine. Supposing if it is 3 days then 3 *0.40.
step 4 : if the days are from 6 to 10
step 5 : this case is above 5 days , therefore calculate for first five days and add the remaining.
step 6 :this is above 10 days,therefore calculate for the first five then the next five finally add the remaining.

Example 2:
Write a program to find the income tax to be paid for the following conditions.
Annual salary                                               Rate of income tax
upto Rs.1,00,000                                           No tax
Rs.1,00,000  to 1,50,000            10% of the amount exceeding 1,00,000
 Rs.1,50,000 to 2,50,000             Rs.5,000+ 20% of                                                       amount exceeding Rs.1,50,000
Above Rs.2,50,000                    Rs.25,000+30% of                                                      amount exceeding Rs.2,50,000

import java.util.*;
class fine
{
public static void main()
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the salary");
int n=s.nextInt();

float amt;
if(n>=1 && n<=1000000)
amt=0;
else if(n>100000 && n<150000)
amt=(10/100)*(n-100000);
else if (n>150000 && n<=250000)
amt=5000+(20/100)*(n-150000);
else
amt=25000+(30/100)*(n-250000);

System.out.print("tax to be paid="+amt);
}
}

Switch :
Write a menu driven program to calculate the area of the following :
circle  - p*r*r [p=3.14]
square -  side * side
rectangle - length * breadth

Display the menu to output the area as per the user's choice.

import java.util.*;
class fine
{
public static void main()
{
Scanner s=new Scanner(System.in);
System.out.println("1.circle");

System.out.println("2.square");
System.out.println("3.rectangle");
System.out.println("Enter your choice");
int ch=s.nextInt();

switch(ch)
{
case 1:
            int r,ac;
            System.out.print("Enter radius");
            r=s.nextInt();
            ac=3.14f*r*r;
            System.out.println("Area of circle="+ac);
            break;
case 2:
            int side,asq;
           System.out.print("Enter side");
            side=s.nextInt();
            asq=side*side;
            System.out.println("Area of square="+asq);
            break;
case 3:
             int l,b,ar;
            System.out.print("Enter length and breadth");
            l=s.nextInt();
            b=s.nextInt();
            ar=l*b;
            System.out.println("Area of rectangle="+ar);
            break;
default :
           System.out.printI("nvalid choice");
    }
  }
}

Loops :
Example 1:
Write a program to input a number and check if it is a palindrome number or not.
A number is said to be Palindrome , if the original number is equal to the reverse number.
class palindrome
{
public static void main(int n)
{
 int m=n;--------------------------------------1
int a,s=0;
while(n>0)-----------------------------------2
{
  a=n%10;------------------------------------3
  s=(s*10)+a;--------------------------------4
  n=n/10;------------------------------------5
}
if(s==m)------------------------------------6
System.out.println("Palindrome number");
else
System.out.println("Not a Palindrome number");
 }
}

step 1: It is important.There should be a copy of the original number,coz we are  going to separate the digit from the number.
step 2:The condition here is n >0 for the reason explained in step1.
step 3: It gives the remainder that is the last digit.
step 4:reverse the number
step 5:Find the quotient
step 6: Check the sum and the copy are same.

Example 2:
Armstrong number.
e.g : 153= 13+53+3
                 =153
class atrmstrong
{
public static void main(int n)
{
 int m=n;
int a,s;
while(n>0)
{
  a=n%10;
  s=s+(a*a*a);--------------------------------1
  n=n/10;
}
if(s==m)
System.out.println("Armstrong number");
else
System.out.println("Not an Armstrong number");
 }
}

only one change in step 1.
Example 3:
Perfect Number :
e.g : 6 the divisors are 1,2,3 and 6.Donot include 6 and add the others it should be equal the original number.
class perfect
{
public static void main(int n)
{
int i,s=0;

for(i=1;i<n;i++)-------------------------------------1
{
  if(n%i==0)-----------------------------------------2
   s=s+i;
}
if(s==n)
System.out.println("Perfect number");
else
System.out.println("Not a perfect number");
 }
}

step 1: the loop should be < n and not <=n
step 2: divide the number from 1 to less than the number, if the remainder is zero then it is a divisor.

Example 4:
Prime number
class prime
{
public static void main(int n)
{
int i,ctr=0;

for(i=1;i<=n;i++)
{
  if(n%i==0)
   ctr=ctr+1;
}
if(ctr==2)
System.out.println("Prime number");
else
System.out.println("Not a prime number");
 }
}

There are different logics. What i used here is, find the number of divisors,if it is 2  i.e 1 and number itself ,then print prime number


Methods or Functions:

An automobile company has increased the cost of its vehicles as per the type of the engine using the following criteria :
Type of engine                                             Rate of increment
2 strokes                                                       10% of the cost
4 strokes                                                       12% of the cost
WAP to use a class to find the new cost as per the given specifications.
     Class name :  Auto
Data members  :  int type(to accept type of engine 2 stroke or  4 stroke)
                                    int cost(to accept previous cost)
        Member methods :
       void get() : accept type of engine
       void find() : find the new cost
       void print() : display type and new cost
  import java.util.*; class Auto
{

int type,cost,rate;
void get(int t,int c)
{
type=t;
cost=t;
}
void find()
{
if(type==2)
rate=(10/100)*cost+cost;
else
rate=(12/100)*cost+cost;
}
void print()
{
System.out.println("Type="+type);
System.out.println("New Cost="+rate);
}

public static void main()
{
Auto ob=new Auto();
Scanner s=new Scanner(System.in);
System.out.println("Enter the type and cost");
int t=s.nextInt();
int c=s.nextInt();
ob.get(t,c);
ob.find();
ob.print();
}
}

Just follow what is given in the question.Use the global variables so that you can use them anywhere in the program.
* DONOT forget to write variable description.
* Read the questions properly.Use the reading time wisely.
* Check the syntax.
* variables should not have space
* There is no semicolon after while,for,if,method,constructor
* If you dont know how to explain the sec A questions , atleast give one example.



That is all I could post  today. I will give section A questions in the coming days .All the best.