Friday, 2 June 2017

PROGRAM 20

CALCULATE THE ECONOMIC RATE OF BOWLER.ACCEPT THE NAME OF THE BOWLER. ACCEPT VALUE OF RUNS CONCEDED BECAUSE OF BOWLER IN FOUR OVERS,
RESPECTIVELY. IF ECONOMIC RATE IS LESS THAN OR EQUAL TO 9 THEN PRINT THAT THE BOWLER IS EXCELLENT.BUT IF ECONOMIC RATE IS MORE THAN 20 THEN PRINT THAT THE BOWLER IS VERY BAD. OTHERWISE IN BETWEEN RATE THEN PRINT THAT BOWLER IS AVERAGE.

Economic rate is the average number of runs conceded for every over bowled.

Example:


PROGRAM:
import java.util.Scanner;
public class economic_rate
{   static int run;
    public static void main (String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the name of the bowler:");
        String s = sc.nextLine();
        int sum=0;
        for(int i=1 ; i<=4 ; i++)
        {
            System.out.println("Enter number of runs conceded in "+i+" over:");
            run=sc.nextInt();
            sum+=run;
        }
        double erate = sum/4;
        System.out.println("Economic rate of the bowler is: " + erate); 
        if(erate<=9){
            System.out.println(s + " is a excellent bowler.");
        }
        else if(erate>9&&erate<=20){
            System.out.println(s + " is a average bowler.");
        }
        else{
            System.out.println(s + " is a very bad bowler.");
        }
    }
}

Tuesday, 30 May 2017

INTRODUCING JAVA ON BLUEJ ENVIRONMENT

THE PROGRAM OR CODE WRITTEN BY PROGRAMMER IS CALLED SOURCE CODE
PROCESS OF CONVERTING SOURCE CODE INTO MACHINE CODE IS CALLED COMPILATION

JAVA BYTE CODE IS A MACHINE INSTRUCTION FOR A JAVA PROCESSOR CHIP CALLED JAVA VIRTUAL MACHINE.
THE BYTE CODE IS INDEPENDENT OF THE COMPUTER SYSTEM IT HAS TO RUN UPON.

FLOWCHART:-
SOURCE CODE(.java)------>byte code(.class)(via compiler)------->My program(via Java VM)

CHARACTERISTICS OF JAVA:-
1.WORA(WRITE ONCE RUN ANYWHERE):JAVA PROGRAMS NEED TO BE WRITTEN ONCE,WHICH CAN RUN ON DIFFERENT PLATFORMS
2.LIGHT WEIGHT CODE
3.SECURITY
4.BUILT IN GRAPHICS
5.OBJECT ORIENTED LANGUAGE
6.SUPPORTS MULTIMEDIA
7.PLATFORM INDEPENDENT
8.OPEN PRODUCT

INTERNET APPLETS:-
INTERNET APPLETS ARE SMALL PROGRAMS EMBEDDED IN WEB PAGES AND ARE RUN ON VIEWER'S MACHINE IN A SECURED MANNER,BY JAVA CAPABLE BROWSERS.

STAND ALONE APPLICATIONS ARE SOFTWARE APPLICATIONS THAT DO NOT REQUIRE LOW LEVEL OPERATING SYSTEMS ON HARDWARE ACCESS


Saturday, 1 August 2015

INTRODUCING CLASSES:

A class is a blueprint of set of objects that share common characteristics and behaviour. An object is its instance.

A method is an association operation of an object. The 'behaviour' of object is represented through methods.

Objects represent the abstraction represented by the class in real sense.

A class represents an abstraction where characteristics are implemented through data and behaviour through methods or functions.

In OOP(object oriented programming), objects are defined by defining a class for them.

Object Factory is producer of objects, that accepts some basic information and creates objects based on that information.

A class is an Object Factory. It contains all statements needed to create an object, its attributes as well as statements describing operations that the object will be able to perform.

CONCEPTS OF OBJECTS:

OBJECTS:

AN OBJECT CAN BE THOUGHT AS AN ENTITY HAVING SPECIFIC IDENTITY , CHARACTERISTICS AND BEHAVIOUR.
 

STATE OF OBJECTS:

THE STATE OF OBJECT IS REPRESENTED THROUGH ITS VALUES OR ATTRIBUTES OF ITS CHARACTERISTICS AT A GIVEN POINT OF TIME.
 

ABSTRACTION:

ABSTRACTION REFERS TO THE ACT OF REPRESENTING ESSENTIAL FEATURES WITHOUT INCLUDING BACKGROUND DETAILS AND EXPLANATION. IT IS ALWAYS RELATIVE TO CONTENT.
 

ENCAPSULATION:

THE WRAPPING UP OF DATA AND FUNCTIONS INTO SINGLE UNIT(OBJECT) IS CALLED ENSCAPSULATION. IT IS THE WAY TO IMPLEMENT DATA ABSTRACTION. IT HIDES THE DETAILS OF THE IMPLEMENTATION OF OBJECTS.
 
 

SINCE STATE AND BEHAVIOUR OF OBJECT ARE INTERWOVEN, THEY ARE SAID TO ENCAPSULATE STATE AND BEHAVIOUR.WE CANNOT SEGRGATE THEM. THUS, WE CAN SAY OBJECTS ENCAPSULATE STATE AND BEHAVIOUR, AS THEIR STATE  AND BEHAVIOUR ARE INTERLINKED. THUS THEY CANNOT EXIST SEPARATELY.

 

STATE IS MAINTAINED THROUGH VARIABLES OR DATA ITEMS (MEMBER VARIABLES THAT HOLD DATA).BEHAVIOUR IS MAINTAINED THROUGH FUNCTIONS OR METHODS

 

WHEN OBJECTS NEED TO INTERACT WITH ONE ANOTHER, THEY INTERACT BY PASSING MESSAGES TO ONE ANOTHER. THIS IS KNOWN AS MESSAGE PASSING.

-------------------------------------------------------------------------------------------------------------------------
 

 

HELLO FRIENDS!
I AM NOW GOING TO HELP YOU GUYS WITH THE THEORY PART OF JAVA ALSO.
MY NOTES WILL DEFINITELY HELP ICSE STUDENTS SCORE MAXIMUM MARKS IN THEIR COMPUTER APPLICATIONS PAPER.

I WILL KEEP UPLOADING MY NOTES ON WEEKLY BASIS.

RIGHT NOW I AM STARTING WITH THE BASIC CHAPTER IN JAVA.

Thursday, 2 April 2015


PROGRAM 19 : ENTER A STRING TO FIND THE LONGEST WORD AND ITS LENGTH.

Example :



PROGRAM :

import java.util.Scanner;
public class wordlengthver2
{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter a string to find longest length:");
        String str = sc.nextLine();
        str = str + " "; // SPACE ADDED TO ENSURE STOPPAGE OF COMPARING AT THE END
        int m = 0 , p;
        String max = "" , c = ""; // CREATING TEMPORARY VARIABLES
        String min = str.substring(0 , str.indexOf(' ')); // EXTRACTS THE FIRST WORD OF STRING
        int l = min.length(); // FINDS ITS LENGTH
        char ch;
        for(int i = 0 ; i<str.length() ; i++){
            ch = str.charAt(i);
            if(ch!=' ') // CHECKING WHETHER EACH CHARACTER IS A WHITE SPACE OR NOT.
                c+=ch; // IF NOT SPACE THAN A WORD IS CREATED
            else{
               p = c.length(); // LENGTH OF THE EXTRACTED WORD.
               if(p>m){ // CHECKS IF THE LENGTH IS GREATER OR NOT
               m = p;
               max = c;
              }
              if(p<l){ // CHECKS IF LENGTH IS LESS
                min = c;
                l = p;
                }
               p = 0; // RESET TO ZERO FOR ANOTHER WORD
               c = "";
            }
        }
        System.out.println();
        System.out.println("LONGEST WORD IN STRING: " + max);
        System.out.println("LENGTH OF THE LONGEST WORD: " + m);
        System.out.println();
         System.out.println("SHORTEST WORD IN STRING: " + min);
        System.out.println("LENGTH OF THE SHORTEST WORD: " + l);
    }
}

Sunday, 29 March 2015

PROGRAM 18 : ENTER A STRING AND REMOVE THE DUPLICATE CHARACTERS OF STRING.

Example :


PROGRAM :

import java.io.*;
class RemoveDupChar
{
      public static void main(String args[])throws IOException
     {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter any word : ");
        String s = br.readLine();
        int l = s.length();
        char ch;
        String ans="";
        for(int i=0; i<l; i++)
       {
            ch = s.charAt(i);
            if(ch!=' ')
                ans = ans + ch;
            s = s.replace(ch,' '); //Replacing all occurrence of the current character by a space
               }
        System.out.println("Word after removing duplicate characters : " + ans);
     }
}