Thursday, 27 October 2016

why we use capacitor in ceiling fan

                                        USE OF CAPACITOR IN A CEILING FAN






Fan mostly operates with a single phase induction motor. As it is not a self starting motor, it needs a rotating magnetic field to start. to two make it a self starting motor a condenser ( usually known as capacitor) is connected to it to give a starting push up , instead of external winding known as auxiliary winding. Single phase supply on stator of this motor  gives alternating magnetic field but we need rotating magnetic field, so we use condensers.  capacitors

are used to split the phase and make it operate like a multi phase motor , so that rotating magnetic field is developed and the motor becomes self starting.
So  capacitor start capacitor run motors are used mostly in ceiling  fans.

Example of reading data through Scanner Class

         USING SCANNER CLASS TO INPUT 


BY USING THIS CLASS WE CAN DIRECTLY CONNECT WITH KEYBOARD. THE MAIN ADVANTAGE OF USING THIS CLASS IS TO READ NUMERIC TYPES OF DATA WITHOUT CONVERTING IT. IT IS AVAILABLE IN java.util PACKAGE. THIS CLASS HAS THE FOLLOWING METHODS :

next( ), nextLine( ), nextByte( ), nextShort( ), nextInt( ),nextFloat( ), nextDouble( ) etc.



Example of using Scanner to a normal results of student program:

   

import java.io.PrintStream;
import java.util.Scanner;
class Program                                         // Program is a Class word and 'P' should be in capital form
{
public static void main(String args[])
{
PrintStream ps = new PrintStream(System.out);
Scanner sc = new Scanner(System.in);
int sno,em,tm,hm,mm,scm,som,tot;
float avg;
String sname,res;
ps.println("Enter Student Number and Name");
sno = sc.nextInt( );
sname = sc.next( );
ps.println("Enter English, Telugu and Hindi Marks");
em = sc.nextInt( );
tm = sc.nextInt( );
hm = sc.nextInt( );
ps.println("Enter Maths, Science and Social Marks");
mm = sc.nextInt( );
scm = sc.nextInt( );
som = sc.nextInt( );
tot = em + tm + hm + mm + scm + som;
avg = tot / 6.0F;
if(em >= 34 && tm >= 34 && hm >= 34 && mm >= 34 && scm >= 34 && som >= 34 && avg >= 80)
{
res = "Distinction";
}
else
if(em >= 34 && tm >= 34 && hm >= 34 && mm >= 34 && scm >= 34 && som >= 34 && avg >= 60)
{
res = "First Class";
}
else
if(em >= 34 && tm >= 34 && hm >= 34 && mm >= 34 && scm >= 34 && som >= 34 && avg >= 50)
{
res = "Second Class";
}
else
if(em >= 34 && tm >= 34 && hm >= 34 && mm >= 34 && scm >= 34 && som >= 34 && avg >= 40)
{
res = "Third Class";
}
else
if(em >= 34 && tm >= 34 && hm >= 34 && mm >= 34 && scm >= 34 && som >= 34 && avg >= 34)
{
res = "Ordinary Pass";
}
else
{
res = "Fail";
}
ps.println("\t\t Abc School");
ps.println("\t\t=================");
ps.println("Student Number : " + sno);
ps.println("Student Name : " + sname);
ps.println("Total Marks : " + tot);
ps.printf("Average Marks : %.3f\n",avg);
ps.print("Result : " + res);
}
}


RESULT:

Enter Student Number and Name
2
JOHN
Enter English, Telugu and Hindi Marks
60
70
87

Enter Maths, Science and Social Marks
90
87
75
Abc School
        =================
Student Number : 2
Student Name : JOHN
Total Marks : 469
Average Marks : 78.167
Result : First Class

Wednesday, 19 October 2016

Inheritance topic

INHERITANCE IN JAVA



INHERITANCE IS THE TECHNIQUE OF EXTENSION OF ALREADY EXISTING CLASS. IT MEANS WE CAN PRODUCE NEW CLASS FROM EXISTING CLASS . IN THIS PROCESS, EXISTING CLASS IS CALLED AS SUPER CLASS / BASE CLASS  AND THE EXTENDED CLASS IS CALLED AS SUB CLASS / DERIVED CLASS / NEW CLASS. SUB CLASS IS 
POWERFUL THAN SUPER CLASS, BECAUSE SUB CLASS HAVE ALL THE FEATURES OF SUPER CLASS AND ADDITIONAL FEATURES OF ITSELF. THE MAIN ADVANTAGE OF INHERITANCE IS REUSABILITY OF CODE. IF WE CREATE AN OBJECT TO SUB CLASS IT CONTAINS A COPY OF SUPER CLASS OBJECT. THAT IS THE REASON WHY SUPER CLASS MEMBERS ARE AVAILABLE TO SUB CLASS. GENERALLY WE DON'T CREATE AN OBJECT TO SUPER CLASS IN INHERITANCE. SO BETTER WAY IS CREATE OBJECT TO SUB CLASS NOT TO SUPER CLASS.
           TYPES OF INHERITANCE
           ======================

            1) SINGLE INHERITANCE

            2) MULTI LEVEL INHERITANCE

            3) HIERARCHICAL INHERITANCE

            4) MULTIPLE INHERITANCE

            5) HYBRID INHERITANCE

JAVA'S RULE IS THAT A CLASS CAN HAVE ONLY ONE SUPER CLASS. SO JAVA DOES NOT SUPPORT MULTIPLE, MULTI PATH AND HYBRID INHERITANCES DIRECTLY.

1)    SINGLE INHERITANCE
   
       DERIVING NEW CLASS FROM SINGLE CLASS.
2)    MULTILEVEL INHERITANCE
     
       DERIVING NEW CLASS FROM ANOTHER DERIVED CLASS.
3)   HIERARCHICAL INHERITANCE

      THIS TYPE OF INHERITANCE IS SIMILAR TO A TREE. IN THIS MODEL EACH SUPER         CLASS HAS MINIMUM TWO SUB CLASSES. GENERALLY IN THIS MODEL OBJECTS           ARE CREATED FROM LEAF NODE (LAST SUB) CLASSES.

          MULTIPLE INHERITANCE  & HYBRID ARE NOT PREFERED.