0% found this document useful (0 votes)
1 views18 pages

FILES

The document presents a project report titled 'JAVA ROOTS' that outlines various concepts of the Java programming language, including methods, inheritance, decision making, looping, string manipulation, and arrays. It includes a certificate of completion, acknowledgments, and sample programs demonstrating Java functionalities such as calculating discounts and implementing sorting algorithms. The project emphasizes the significance of Java as a versatile and widely-used programming language.

Uploaded by

Ajay Dhiman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views18 pages

FILES

The document presents a project report titled 'JAVA ROOTS' that outlines various concepts of the Java programming language, including methods, inheritance, decision making, looping, string manipulation, and arrays. It includes a certificate of completion, acknowledgments, and sample programs demonstrating Java functionalities such as calculating discounts and implementing sorting algorithms. The project emphasizes the significance of Java as a versatile and widely-used programming language.

Uploaded by

Ajay Dhiman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

On this ideal opportunity, I am very glad to thanks and to

express my sincere feelings to all who have come across this


project.I take this opportunity to express my deep regards to
my teacher “............................” her help.In this project “JAVA
ROOTS” I would not forget the contribution of my school staff
member especially of the principal of our school
“........................” for her help. I would like to convey my
heartiest thanks to all for the help provided by them in
completing this project through various stages. I have tried
my level best to make this project a great success and it was
impossible for me to complete this project without the help
of my dedicated to devoted teachers, parents and friends.
CERTIFICATE

DEPARTMENT OF COMPUTER APPLICATION


This is to certify that the Project Report entitled as:

“ JAVA ROOTS” is a Bonafide record of work done by :


...............of x ................
In partial fulfilment of the requirement of I.C.S.E. Computer Applications Examination

under the school St. Mary’s Convent School, Narwana.

Signature: Signature:

(External Examiner) (Internal Examiner)


1.)INTRODUCTION

2.)METHOD OR FUNCTON
(THEORY, ALGORITHM,FLOWCHART & PROGRAM)

3.) ARRAYS
(THEORY, ALGORITHM, FLOWCHART & PROGRAM)

4.) CONSTRUCTOR
( THEORY, ALGORITHM, FLOWCHART & PROGRAM)

5.) DESION MAKING AND LOOPING


(THEORY, ALGORITHM, FLOWCHART & PROGRAM)

6.) STRING MANIPULATION


(THEORY, ALGORITHM, FLOWCHART & PROGRAM)

7.) INHERITANCE

(THEORY, ALGORITHM, FLOWCHART & PROGRAM)


Programming languages.Paradigms and practices don’t stand still very
long.It often seems that methods and techniques we applied yesterday are
out of day today.Of course,this rapid rate of change is also one of the things
that keeps programming exciting.There is always something new on the
horizon. When the chronicle of computer languages is written the following
will be said:

B led to C,C evolved to C++,and C++ set the stage for java.

Perhaps no language better exemplifies the preceding statements


than java grew from a concept into one of the world’s dominant computer
language .

This project has been divided into six topics:


1.) METHOD OR FUNCTION:- It defines the function or method of java language .
2.) INHERITENCE:- This topics introduces that how the objects are inherited i.e. some
important information about inheritance , which is a property of OOP’S ( Object
Oriented Programming).
3.) DECISION MAKING AND LOOPING:- This topic introduces some information on
selection statements and loops .
4.) CONSTRUCTERS:- This topic is dedicated to discussion of constructor, which is a
special type of function.
5.) STRING MANIPULATION:- This topic introduces the Library classes and their
significance, String Handling and Character Handling.
6.) Arrays:- This topic introduces some information of Arrays and it’s kind (1-D and
2-d).As Arrays form an important part of java programming language and hence
the project have been incomplete without it.
Java is a general-purpose,concurrent,class,based,object-oriented
language.It is designed to be simple enough that many programmers can achieve fluency
in the language.Java is related to C and C++ but is organized rather differently with a
number of aspects of C and C++ omitted and a few ideas from other languages and
environment invented by JAMES GOSLING and others in 1994.Java was originally
named OAK and was developed as a part of green project at Sun Microsoft company.the
writing of java began in December of 1990.
Java programs fall into two categories, consist of stand alone application and
internet applets.1st,stand alone application uses the resources of single computer which
does not require a low-level operating system.2nd,internet applets are small programs that
are embedded 1 in web pages and are run on the viewers machine in secured manner of
java capable browers.
Some important features of java are :
1. Simple
2. Secure
3. Portable
4. Object oriented
5. Robust
6. Multithreaded
7. Architectural neutral
8. Interpreted
9.High performance
10.Distributed
11.Dynamic


A program module or a part of the program used simultaneously at different
instances in the program is known as Method or Function. In Java programs, the
executable instructions are specified through methods or functions.
The general form of function definition is as given below:
[Access specifier] [Modifier] return-type function name (parameter list)
{
Body of the function
}
Access specifier used to determine the type of access to the function. It can be either
public or protected or private.
Modifier can be one of: final, native, synchronized, transient, volatile.
Return_type specifies the type of value that the function returns. It may be of any valid
type data_type.If no value is being returned, it should be void.
A Function may be without any parameters, in which case, the parameter list is empty. A
function is invoked in two manners:Call by Value and Call by Reference. Basically these
two ways of invoking
Functions are also referred to as Pass by Value and Pass by Reference. These are
discussed in brief as under:

PASS BY VALUE (CALL BY VALUE)


The call by value method copies the value of actual parameters into
formalparameters, that is,the function creates its own copy of arguments values and then
uses them. The main benefit of call by value is that you can’taltyer the variables that are
used to call the functionbecause any change that occurs inside the function is on the
function’s copy of the argument value.The original copy of the argument value remains

intact.Thus,in call by value method,the changes are not reflected back to the original
values.
CALL BY REFRENCE
In call by value method,the called function creates a new set of variables and copies
the values of arguments into them. The function does not have access to the original
variable and can only work on the copies of value it created. The call by value method
also offers insurance that the function can’t harm the original value. The call by reference
method uses a different mechanism. In place of passing a value to the function being
called a reference to the original variable.Thus,in call by reference method the changes are
reflected back to the original values.
PROGRAM
A cloth showroom has announced the following festival discounts on the purchase of
items, based on the total cost of the items purchased:

Total cost Discount (in Percentage)

Less than Rs.2000 5%


Rs.2001 to Rs. 5000 25%
Rs.5001 to Rs. 10000 35%
Above Rs. 10000 50%

Write a program to input the total cost and to compute and display the amount to paid
be
customer after availing the discount.
//To compute festival discount
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class DiscountFest {
public static void main(String[] args) throws IOException {
System.out.println("Enter the no. of items you have purchased:");
BufferedReader bf;
bf= new BufferedReader(new InputStreamReader(System.in));
String InputValue = (String) bf.readLine();
int ItemCount = Integer.parseInt(InputValue);
double totalCost = 0;
for (int i=0;i<ItemCount;i++)
{
System.out.println("Enter the cost of item" + (i+1)+":");
bf = new BufferedReader(new InputStreamReader(System.in));
InputValue = (String) bf.readLine();
totalCost += Integer.parseInt(InputValue);
}
System.out.println("Total is cost is: " + totalCost);
if(totalCost<=2000)
{
totalCost =totalCost - totalCost*0.05;
System.out.println("Amount to pay after 5% Discount is: " +
totalCost);
}
else if(totalCost>2000 && totalCost<=5000)
{
totalCost =totalCost - totalCost*0.25;
System.out.println("Amount to pay after 25% Discount is: " +
totalCost);
}
else if(totalCost>5000 && totalCost<=10000)
{
totalCost =totalCost - totalCost*0.35;
System.out.println("Amount to pay after 35% Discount is: " +
totalCost);
}
else if(totalCost>10000)
{
totalCost =totalCost - totalCost*0.5;
System.out.println("Amount to pay after 50% Discount is: " +
totalCost);
}
}
}

An array is a group of like-typed variables that are referred to by a common


name.Arrays of any type can be created and may have one or more dimensions.A specific
element in an array is accessed by it’s index.Arrays offer a convenient means of grouping
related information’s.
Types of Arrays:-
1.One-Dimensional Array:-A one-dimensional array is a list of variables that are of the
same type and are referenced through a common name.An invidual variable in the array is
called an array element.Arrays provide a convenient method to handle groups of related
data.
To declare a one-dimensional array,use the general form
Data_type [size] array_name;
Where,data_type is a valid java data type,array_name is the name of the array and the
size specifies the name of elements in the array.The size is also an integer expression.
2.Multidimensional arrays :- A multidimensional array is an array with more than one
subscript.A single dimensional array is a list of values,but a multidimensional array
simulates a table of values or even multible table of values.The most commonly used table
is two dimensional table.To declare multi dimensional use the general form:
data_type [row] [column] array_name;
where data_type is a valid java data type,array _name is the name of the array.Row and
column specifies the dimensions of array.

Searching:-
The process of finding a particular element of an array is called searching.
Types of searching:
There are two types of searching:-
1.Linear Search:- Linear search examines each value in turn until the target is found or
the end of the list is reached.
2.Binary Search:-The binary search algorithm requires that the list is sorted,but peovides
significant improvements in efficiency over a linear search.

Sorting Arrays:-
Sorting of an array means arranging the array elements in a specified order.
Types of sorting:-
1.Linear Sort:- This sorting method is based on comparing and exchanging the top
element with least value,until all elements in an array are stored.
2.Bubble Sort:-This sort method is based on comparing and exchanging pairs of adjacent
elements,until all the elements in an array are sorted.
3.Selection sort:- Selection sort works by putting each value into it’s final position one at
a time.
4.Insertion sort:-Insertion sort works by inserting each value into a previously sorted
subset of the list.
FLOW CHART

:-Write a program to bubble sort the following set of values in ascending


order
5, 3, 8, 9, 2, 1, 98, 16
//To sort an array using Bubble Sort

public class BubbleSort {

public static void main(String[] args) {

// TODO Auto-generated method stub

//int x[] = new int[10];

//x[0]=5;x[1]=3;x[2]=8;x[1]=3;x[1]=3;x[1]=3;x[1]=3;x[1]=3;x[1]=3;x[1]=3;

int x[]={5,3,8,4,9,2,1,12,98,16};

int n = x.length;

for (int pass=1; pass < n; pass++)

// count how many times

// This next loop becomes shorter and shorter

for (int i=0; i < n-pass; i++)

if (x[i] > x[i+1]) {

// exchange elements

int temp = x[i]; x[i] = x[i+1]; x[i+1] = temp;

for (int i=0;i<n;i++)

System.out.println(x[i]);

}
The constructors has the same name as the class.The constructors has no return
value specification not even void.they are certainly not instance methods.since they don’t
belong to object,since they are responsible for creating objects,they exist before any
objecthas been created.According to the java language specifications,they are technically
not members of the class at all in particular,constructors are not referred to as “methods”.

CHARACTERISTICS:
i. It has no return type not, even void.
ii. It is called when the object is created.
iii. It has function name same as the name as its class.
iv. It can be called either implicity or explicity.

:-Types of constructors:
There are two types of constructors:
1. Parameterized constructors:- the parameterized constructors can pass value into the
constructors that have different parameters in the constructors functions.
For example, the constructor declared as:
Teacher(String,String,String,Double)// parameterized constructors means that the
teacher constructors has four parameter’s in its body. There would be four values or four
variables values would be passed to theparameterized constructor.
2. Non-parameterized constructors:-These are also known as default constructors because
it declares no parameters. The constructor can declare its function body either inside the
class as:
Teacher( )
{
Salary = 8000;
}
The aforementioned default constructor initializes a value 8000 to the private data
member salary.
To avoid confusion for the compiler with same name of the instance variable. The this
keyword can be implicit or explicit . In implicit this java itself uses keyword this to refer
to data member of object.

Constructors are a primary candidate for overloading. By providing multiple versions of


a constructor, you have a variety of ways to create and initialize an object.
Write a program to find Simple intrest with constructer method.

//To find Simple intrest using constructer

public class intrest

double ROI; //rated intrest

intrest (double a)

ROI = a;

public double simpleintrest(double x,double y)

return( (x*y*ROI)/100);

public static void main(String args[])

{
intrest i=new intrest(5.2);

double SI=0.0;

SI=i.simpleintrest(1000,3);

System.out.println("SI on 1000Rs. for 3 years at 5.2% =" +SI);

OUTPUT OF THE PROGRAM


SI on 1000Rs. for 3 years at 5.2% = 156.0


SELECTION STATEMENT:- The selection statement is also called decision


statement.This statement allow choosing the set-of-instructions for executing depending
upon an expression’s truth value.
TYPES OF SELECTION STATEMENT :-
Java provides two types of selection statement:
1. If statement
2. The while statement

THE IF STATEMENT :- The if statement allows branching depending upon the


value or state of variable. In java the if statement is used with relational operators. This
statement is called decision making because it tests a relationship, using the relational
operator. Then it make a decision about which statement to execute next , based on the
result of that decision. The if statement as the following format.
If (condition)
{
Statement;
}

THE WHILE STATEMENT: - The while statement is one of several java construct
statement. A construct is a programming language statement of a series of statements
that controls looping. The while is a looping statement. Looping statement controls
execution of a series of other statement, causing parts of a program to execute repetectly
as long as a certain statement is end.
REMARKS

MARKS OBTAINED: ___________

TEACHER’S SIGN : __________



You might also like