Title: Hello Java
1Hello Java!
Celebrate IEEE Day with Coding Java
L E V E L
Raaid Alubady
1
2Outline
Hello Java
- Beginning in Java
- Beginning in Java
- Components of Java Programming
- Java Variable and Data Type
- Components and Control Tools
- 2.1. Data input
- 2.2. Data output
- 2.3. Condition statements
- 2.4. Loop statements
-
- Array and Methods
Hello Java
Hello Java
2
Advanced Java Programming
3Beginning in Java
Hello Java !
- Sun Microsystem (by James Gosling) began
developing Java behind closed door in 1991. It
wasn't reveal to the public until 1995. - The original name of Java was intended to be
"OAK", Other names floating around were "Silk"
and "DNA". - Java is a programming language expressly designed
for use in the distributed environment of the
Internet. It was designed to have the "look and
feel" of the C language, but it is simpler to
use than C and enforces an object-oriented.
Java can be used to create complete applications
that may run on a single computer or be
distributed among servers and clients in a
network. It can also be used to build a small
application module or applet for use as part of a
Web page.
4Beginning in Java
Hello Java !
- Characteristics of Java
- Easy to learn
- Platform independent (not access directly system
resources) - Object-orientated programming language
- Interpreted and compiled language (source code
byte-code) - Automatic memory management
Java IDE Tools
- Inprise JBuilder
- Microsoft Visual J
- Symantec Café
- Forte by Sun MicroSystems
- IBM Visual Age for Java
- Eclipse
- NetBeans 6.0 (free, open-source IDE, runs on
Windows, Linux, Solaris, and the MacOS) - JCreator LE 4.0 (free) by Xinox Software
5Beginning in Java
Hello Java !
Why Program in Java?
6Beginning in Java
Hello Java !
Why Program in Java?
7Beginning in Java
Hello Java !
Ready to learn JAVA. If so, switch on your
laptop.
JAVA
Next , open Eclipse...
8Beginning in Java
Hello Java !
Java API, JDK and IDE
API
(Application Programming Interface)
- Contains predefined classes and interfaces for
developing Java programs.
- Three editions of Java API
- Java SE A Standard Edition targeted at
developing console, desktop client, and server
applications. - Java EE An Enterprise Edition targeted at
developing large-scale industry enterprise
applications. - Java ME A Micro Edition targeted at developing
mobile, hand-held device applications.
9Beginning in Java
Hello Java !
Java API, JDK and IDE
JDK
(Java Development Kit) A set of programs for
developing and testing Java program, each of
which is invoked from a command line.
IDE
(Integrated Development Environment) Software
that provides integrated development environment
(editing, compiling, building, debugging and
online help) for rapidly developing Java program
10Beginning in Java
Hello Java !
Create the first project
1
2
3
4
11Beginning in Java
Hello Java !
Create the first project
6
5
12Beginning in Java
Hello Java !
Create the first project
7
8
9
13Beginning in Java
Hello Java !
Create the first project
10
14Beginning in Java
Hello Java !
First Example Hello class with Java
15Beginning in Java
Hello Java !
- Components of Java Programming
- Comments.(to illustrate the programs steps and
comments) - Project. (it using to include one or more package
in one project) - Package. (it using to include one or more class
in one package) - Class.(at least one in one project)
- Main Method.(at least one in one project and its
use for project execution) - Other methods. (the main class might be included
many methods) - Blocks.(codes must be organize)
- Reserved Keyword. (such as private, String,
extends, class, and so on) - Instructions.(language format)
- Access specify. (like public, private, protected)
16Beginning in Java
Hello Java !
Java Variable and Data Type
- Local variable. declared within a method in a
class. - Instance variable. declared within a class but
outside any method. - Static variable. declared within a class
as static.
Declaring variable ltltdatatypegtgt
ltltvariableNamegtgt Example int count double
radius double total Or double radius, total
17Beginning in Java
Hello Java !
Note1 The Java syntax is similar to C. Java
is case sensitive, e.g. the variables myValue
and myvalue will be treated as different
variables.
Note2 In Java, the equal sign () is used as the
assignment operator.
- Note3 The name of a variable can be made of one
letter (a, b, c, d, e, f, g, h, i, j, k, l, m, n,
o, p, q, r, s, t, u, v, w, x, y, z,A ,B, C, D, E,
F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U,
V, W, X, Y, or Z) . - Note4 The name of a variable can start with a
letter, an underscore "_", or the dollar sign . - Note5 After the first character, the name of the
variable can include letters, digits (0, 1, 2, 3,
4, 5, 6, 7, 8, or 9), or underscores in any
combination
18Beginning in Java
Hello Java !
Note6 The name of a variable cannot be one of
the words that the Java languages has reserved
for its own use.
abstract assert boolean break byte
case catch char class const
continue default do double else
enum extends final finally float
for goto if implements Import
intanceof int interface long native
new package private protected public
return short static strictfp super
switch synchronized this throw throws
transient try void volatile while
19Beginning in Java
Hello Java !
Instance variables access specification
Visibility Default (friendly) public protected Private
From the same class Yes Yes Yes Yes
From any class in the same package Yes Yes No No
From any class outside the package No Yes No No
From a subclass in the same package Yes Yes Yes No
From a subclass outside the same package No Yes Yes No
Hello Java !
Note7 this table is same when instance methods
and inner class access specify.
19
20Components and Control Tools
Java Data Input and out put
Input by Console Scanner
Output by System.out
- In Java we can use Scanner class.
- First step, declare a Scanner object.
- Scanner scan new Scanner (System.in)
- System.in is a object represents the standard
input stream, which by default is the keyboard. - The object scan reads the input in many ways
- scan.nextInt()
- scan.nextDouble()
- scan.nextFloat()
- scan.next()
- scan.nextLine()
- java.util.Scanner class library should be
imported in order to used this object.
System.out.print( ) without new line Or
System.out.println( ) with new line
- import java.util.Scanner
- public static void main( String args )
-
- int x9, y8, z
- zxy
- System.out.print (x)
- System.out.print (y)
- System.out.print (z)
- System.out.println ()
- System.out.println(x)
- System.out.println(y)
- System.out.println(z)
- System.out.println("the result " z)
- // end of main method
- // end of main class
Hello Java !
import java.util.Scanner public class
Read_Scanner public static void main( String
args ) Scanner in new Scanner( System.in
) System.out.print( in.nextLine() ) //
end of main method // end of main class
9817
Output
9
8
17
The result 17
21Components and Control Tools
Java Data Input and out put
import java.util.Scanner public class test
/ This program is basic calculator
/ public static void main(String args) //
double elmFirst, elmSecond, elmSum
System.out.print("Enter the First element ")
Scanner in new Scanner( System.in )
elmFirst in.nextDouble()
System.out.print("Enter the Second element ")
elmSecond in.nextDouble() elmSum elmFirst
elmSecond System.out.println("The answer is "
elmSum)
Hello Java !
Enter the First element 3.6 Enter the Second
element 9.23 The answer is 12.83
Output
22Components and Control Tools
Condition Stracture
- The if selection structure (single or multiple
selection structure) - Conditional operator ? (ternary conditional)
- The switch selection structure (multiple-selection
structure)
if, if/else, instance if Statement
Syntax if (condition(s)) statement or block
of statements Or if (condition(s))
statement or block of statements
else statement or block of statements
Hello Java !
The condition is a Boolean comparison that can
use one of the binary operators ,
! , gt , lt , gt , lt In addition to the Boolean
operators (AND), (OR), and ! (NOT). Of
course combinations can occur using brackets ( )
23Components and Control Tools
if, if/else, nistens if Statement
- Example
- if (x ! y)
- System.out.println (Not Equal)
- Example
- if (studentGrade gt 60)
- System.out.println (Passed)
- else System.out.println (Failed)
- Example
- if (totalSumlt50)
- // no discount
- System.out.println (No discount)
- System.out.println (Payment is totalSum)
-
- else //10 discount
- totalSumtotalSum-(totalSum0.1)
- System.out.println (Payment with
discount is totalSum) -
Hello Java !
24Components and Control Tools
Conditional operator
Syntax (condition (s) ? statement1
statement2
Example System.out.println (studentGrade
gt 60 ? Passed Failed)
Example
import java.util.Scanner public class test
public static void main(String args) //
test Conditional operator int mark
System.out.print("Enter the mark ") Scanner
in new Scanner( System.in ) mark
in.nextInt() mark mark gt 50 ? mark10
mark-5 System.out.println("The answer is "
mark)
Hello Java !
25Components and Control Tools
Switch selection structure
Syntax switch (variable) case value_1
statement or block of statements break
case value_2 statement or block of
statements break case value_3
statement or block of statements break
................................................
............................................
..........................................
..................................................
case value_n statement or block of
statements break default
statement or block of statements
Example System.out.print("Enter the mark ")
Scanner in new Scanner( System.in ) i
in.nextInt() switch (i) case
1 System.out.println (Read) break
case 2 System.out.println (Blue) break
case 3 System.out.println(Black
) System.out.println(Unknown)
default //end of switch
Hello Java !
26Components and Control Tools
Exercise1 Write a program in Java to find out
if a number is prime in Java? (input 7 output
true , input 9 output false). A number is
called prime if it is divisible by either itself
or 1.
Exercise2 Write Java program to check if a
number is palindrome in Java? ( 121 is
palindrome, 321 is not). A number is called a
palindrome if number is equal to reverse of
number e.g. 121 is palindrome because reverse of
121 is 121 itself.
Exercise3 Write a program in Java to check if a
number is even or odd in Java? (input 2 output
true, input 3 output false). A number is called
even if it is completely divisible by two and odd
if its not completely divisible by two. For
example number 4 is even number because when you
do 4/2 , remainder is 0 which means 4 is
completely divisible by 2. On the other hand 5 is
odd number because 5/2 will result in remainder
as 1
Hello Java !
Exercise4 Write a program called
PrintNumberInWord which prints "ONE", "TWO",... ,
"NINE", "OTHER" if the int variable "number" is
1, 2,... , 9, or other, respectively. Use (a) a
"nested-if" statement (b) a
"switch-case" statement.
27Components and Control Tools
Loop Statements
- for loops
- while loops
- do/while loops
for loops
Syntax for ( initializations condition(s)
increment/ decrement )
statement or block of statements
Hello Java !
Example for (int i0 ilt10 i)
System.out.println ("the value
I is" i)
28Components and Control Tools
public class test / This program is test
for statement / public static void
main(String args) for(int
i1ilt10i) if ((i2)0)
System.out.println("The i " i " is
event") else System.out.println("
The i " i " is odd") //end for //end
main //end class
What does the result
Hello Java !
public static void main(String args) int i
for(i1ilt10i) System.out.println("the
result " i) //end main
29The sum is 5050 The average is 50.5
Components and Control Tools
public class test / This program is test
for statement / public static void
main(String args) int i int ii int sum
for(i0ilt10i) sum0
for(iiiiilt10ii) sumii //
end second for System.out.println("the result
" sum) // end first for //end
main //end class
Hello Java !
Exercise5 Write a program called SumAndAverage
to produce the sum of 1, 2, 3, ..., to 100. Also
compute and display the average. The output shall
look like
The sum is 5050
The average is 50.5
30Components and Control Tools
while structure
Syntax while ( condition(s) )
statement or block of statements
Example int numberCount 1 //
this step very important while
(numberCountlt10)
System.out.println (numberCount)
numberCount
import java.util.Scanner public class test
//This program is test while public static void
main(String args) int numberCount
System.out.print("Enter the mark ") Scanner
in new Scanner( System.in ) numberCount
in.nextInt() while (numberCount10)
System.out.println (numberCount)
numberCount // end while
System.out.println("The answer is "
numberCount)
Hello Java !
31Components and Control Tools
do / while structure
Syntax do
statement or block of statements
while ( condition(s) )
Example int numberCount 10
do System.out.println
(numberCount) numberCount--
while (numberCountgt0)
Exercise6 Modify the program to use a
"while-do" loop instead of "for" loop.
Exercise7 Modify the program to use a
"do-while" loop.
Hello Java !
Exercise8 What is the difference between "for"
and "while-do" loops? What is the difference
between "while-do" and "do-while" loops?
Exercise9 Write a program called Fibonacci to
display the first 20 Fibonacci numbers F(n),
where F(n)F(n1)F(n2) and F(1)F(2)1. Also
compute their average. The output shall look
like The first 20 Fibonacci
numbers are 1 1 2 3 5 8 13 21 34
55 89 144 233 377 610 987 1597 2584 4181 6765
The average is 338
32Array and Methods
Hello Java !
Java Arrays Array is the most important thing
in any programming language. By definition, array
is the static memory allocation. It allocates the
memory for the same data type in sequence.
- There are two type of array
- Single-dimensional
- Two-dimensional
Single-dimensional
Example int num num new int
6 or we can also
int
num new int 6 or like this
int num new int 6
33Array and Methods
Hello Java !
Some times user declares an array and it's
size simultaneously. You may or may not be define
the size in the declaration time. such as int
arraytest 50,20,45,82,25,63
When we declare the definition of array like
that int arraytest this will be in memory
like below -
int arraytest 50,20,45,82,25,63
arraytest
33
Advanced Java Programming
34Array and Methods
Hello Java !
import java.util.Scanner public class test
/ This program using to find the repeated
max integer / public static void main(String
args) int numberCount final int num6
// final means const in another language
int numbersnew int num // Input
data section for(int i0iltnumbers.lengthi)
System.out.print("Enter the elment ")
Scanner in new Scanner( System.in )
numbersi in.nextInt() //end for
//Processing 1 section int
maxnumbers0 for (int
i0iltnumbers.lengthi) if
(maxltnumbersi)
maxnumbersi //end for
//Processing 2 section int count0
for (int i0iltnumbers.lengthi)
if (numbersimax)
count // end for
//Output data section System.out.print("the array
data are " ) for(int i0iltnumbers.lengthi) S
ystem.out.print(numbersi " ") //output all
array data System.out.println("\n the largest
number is " max) // output the
max System.out.println("the occurrence count of
the largest number is " count) // output the
freguncy of max
Enter the elment 4 Enter the elment 8 Enter the
elment 0 Enter the elment 9 Enter the elment
3 Enter the elment 9 the array data are 4 8 0 9
3 9 the largest number is 9 the occurrence
count of the largest number is 2
Output
35Array and Methods
Hello Java !
Two Dimensional Array
Declaration Syntax DataType
ArrayRefVarnew DataTypesizeofrowsizeofcolumn
Example int num num new int
66 or we can
also int
num new int 66 and also we can
write
int num new int 66
Exercise10 Write program to sort an integer
array? arrayElm5.
Exercise11 Write program to sort an integer two
dimensional array? arrayElm55.
36Array and Methods
Hello Java !
Java Methods
In programming, experience has shown that the
best way to develop and maintain a large program
is to construct it from small, simple pieces or
modules. This technique is called divide and
conquer. Modules in Java are called methods and
classes. Many methods and classes are already
available prepackaged in the Java API (Java
Class Library).
One of the important classes in Java is the Math
class that has many methods allowing the
programmer to perform certain common mathematical
calculations. The Math class is part of the
java.lang.Math package, which is automatically
imported by the compiler.
Example System.out.println (Math.sqrt(900.0)) Sy
stem.out.println (Math.sin (0.0))
For more details and methods visit the
website https//docs.oracle.com/javase/7/docs/api
/java/lang/Math.html
37Array and Methods
Hello Java !
Java Methods
Java library methods
Users-defined methods
Main method
Constructor methods
- Any method in java contain two part method
header and method body
lt method_specifygt ltreturn_typegt
ltmethod_namegt (lt formal parameters gt)
// method body (declarations and
statements)
Note the bracket , means inside it optional.
- Important notes
- If the return type is void then the return
statements inside the method should return
nothing. - Dont put a semicolon after the first line of the
method definition. - Each variable in the parameter list should have a
type. - A method cannot be defined inside another method.
38Array and Methods
Hello Java !
Main method
Declaration public
static void main(String args)
// method
body (declarations and statements)
Constructors method
public class A public A( ) public A(int
m) ..
Users-defined method
public double maximum (double x, double)
if (xgty) return x return y
Java library method
Math.max ( x, Math.max ( y, z))
39Array and Methods
Hello Java !
Very Important note
Methods in the same class public class A public
static void main(String arg) public
static int max(int a, int y) . public
static boolean check(boolean a) .. . .
. end class A
Methods in the different class public class
A public static void main(String
arg) public static int max(int a, int
y) . // end class A public class
B public boolean check(boolean a) public
double sum(double arr) . //end class B
40Array and Methods
Hello Java !
Users-defined method
Value-returning methods
Void methods
- Value-returning methods have return type
- Return a value of a specific data type using
return statement - The returned value can be used in one of the
following scenarios - Save the value for further calculation
- Example int out
- outmax(a , b)
- Using the value in some calculation
- Example outmax(a , b)/2
- Print the value
- Example System.out.print(max(a , b))
- Void methods do not have return type (i.e.
return 0) - Do not use a return statement to return a value
41Array and Methods
Hello Java !
Invoking method
method_name(Actual parameters without data
type)
Example int data
(55,72,35,19,74 sum(data)
public class Methods public static
void DisplayMyInfo ( )
System.out.print("My name is Mhamad Harmush
\n") System.out.print("I made harmash.com
when i was 20 years old \n")
System.out.print("I love programming \n")
public static void main (String args)
DisplayMyInfo()
42Array and Methods
Hello Java !
import java.util.Scanner public class test
// This program using to find the factorial to
any number public static void main(String
args) int elm System.out.print("Enter the
number ") Scanner in new Scanner( System.in )
elm in.nextInt() System.out.print(fact(elm
)) // call method // end main
method public static int fact(int dat) int
result1 for(int idat igt0 i--) resulti retu
rn result // end fact method
Enter the number 5 120
Output
43Array and Methods
Hello Java !
import java.util.Scanner public class test
// This program using to find the factorial to
any number public static void main(String
args) int elm System.out.print("Enter
the number ") Scanner in new Scanner(
System.in ) elm in.nextInt() fact(elm) //
call method // end main method public
static void fact(int dat) int result1 for(int
idat igt0 i--) resulti
System.out.print(result) // end fact method
Enter the number 5 120
Output
44Array and Methods
Hello Java !
import java.util.Scanner public class test
// This program using to find the factorial to
any number public static void main(String
args) int elm System.out.print("Enter the
number ") Scanner in new Scanner( System.in )
elm in.nextInt() System.out.print(fact(elm
)) // call method // end main
method public static int fact(int dat) int
result1 for(int idat igt0 i--) resulti retu
rn result // end fact method
Enter the number 5 120
Output
45Array and Methods
Hello Java !
import java.util.Scanner import
java.lang.Math public class test / to
demonstrate the all concept above / public
static void main(String args) String
circleArray"Red", "Yellow", "Black",
"White" double radius1, radius2
for(int i 0 ilt circleArray.length i)
radius10 radius20 System.out.print("Enter
the radius1 for Circle " circleArrayi " ")
Scanner in new Scanner( System.in )
radius1 in.nextDouble() System.out.print("En
ter the radius2 for Circle " circleArrayi "
") Scanner inn new Scanner( System.in )
radius2 inn.nextDouble() if ((radius1
lt 0.0) (radius2 lt 0.0))
ExceptionError() // Invoking void method
46Array and Methods
Hello Java !
else double radiusMath.max(radius1,
radius2) // Invoking Java library method
System.out.println("The area for Circle "
circleArrayi " is " radius) //
Invoking Users-defined methods
System.out.println("The area for Circle "
circleArrayi " is " getArea(radius))
System.out.println("The area for Circle "
circleArrayi " is " getDiameter(radius))
System.out.println("The area for Circle "
circleArrayi " is " getCircumference(radius)
) // end else // end for //
end main method // Declaration users - Value
return methods public static double
getArea(double radius) return Math.PI radius
radius // end method
47Array and Methods
Hello Java !
public static double getDiameter(double
radius) return radius 2 // end method
public static double getCircumference(double
radius) return Math.PI radius 2 //
end method // Declaration users - Void
methods public static void ExceptionError() Syste
m.out.println("The radius is not except")
// end method //end class
Enter the radius1 for Circle Red 3.7 Enter the
radius2 for Circle Red 6.2 The area for Circle
Red is 6.2 The area for Circle Red is
120.76282160399165 The area for Circle Red is
12.4 The area for Circle Red is
38.955748904513435 Enter the radius1 for Circle
Yellow 5 Enter the radius2 for Circle Yellow
4.1 The area for Circle Yellow is 5.0 The area
for Circle Yellow is 78.53981633974483 The area
for Circle Yellow is 10.0 The area for Circle
Yellow is 31.41592653589793 Enter the radius1
for Circle Black 5.8
Output
48Array and Methods
Hello Java !
Enter the radius2 for Circle Black 4.3 The area
for Circle Black is 5.8 The area for Circle
Black is 105.68317686676063 The area for Circle
Black is 11.6 The area for Circle Black is
36.4424747816416 Enter the radius1 for Circle
White 1.9 Enter the radius2 for Circle White
1.8 The area for Circle White is 1.9 The area
for Circle White is 11.341149479459153 The area
for Circle White is 3.8 The area for Circle
White is 11.938052083641214
import java.util.Scanner public class test
/ to demonstrate the all concept above
/ public static void main(String args) int
val0 int data4, 16, 2, 8, 3,
9, 5, 11, 2, 25, 2, 3, 14, 7,
0, 21, 15, 3, 6, 23,
19, 8, 23, 7, 21
49Array and Methods
Hello Java !
do System.out.println("Array Operations") System
.out.println("---------------------------------")
System.out.println("1- Print Main
Diagonal") System.out.println("2- Print
Secondary Diagonal") System.out.println("3-
Print Upper Triangle") System.out.println("4-
Print Lower Triangle") System.out.println("5-
Return the Avarage ") System.out.println("6-
Return the First Odd Data ") System.out.println("
7- Return the Least Even Data ") System.out.print
ln("8- Print the Array ") System.out.println("0-
Exit ") System.out.println("---------------------
-------------") System.out.print("Enter your
choice ") Scanner in new Scanner( System.in
) valin.nextInt() switch (val) case 1
mainDiagonal(data) break case 2
secondaryDiagonal(data) break case 3
upperTriangle(data) break case 4
lowerTriangle(data) break case 5 float
resultarrayAvarge(data)
System.out.println(result) break
50Array and Methods
Hello Java !
case 6 int resultfirstOddData(data)
System.out.println(result) break case 7
int resultleastEvenData(data)
System.out.println(result) break case 8
print(data) break default System.out.println(
" Exit") while (val ! 0) // end main
method public static void mainDiagonal(int
data) for(int i0 ilt5 i) for(int j0
jlt5 j) if (i j)
System.out.print(" " dataij)
System.out.println() public
static void secondaryDiagonal(int
data) for(int i0 ilt5 i)
51Array and Methods
Hello Java !
for(int j0 jlt5 j) if (ij 4)
System.out.print(" " dataij)
System.out.println() public
static void upperTriangle(int data) for(int
i0 ilt5 i) for(int j0 jlt5 j) if (iltj)
System.out.print(" " dataij)
System.out.println()
public static void lowerTriangle(int
data) for(int i0 ilt5 i) for(int j0
jlt5 j) if (igtj) System.out.print("
" dataij) System.out.println()
52Array and Methods
Hello Java !
public static void print(int data) for(int
i0 ilt5 i) for(int j0 jlt5 j)
System.out.print(" " dataij)
System.out.println() public static
float arrayAvarge(int data) float avg
int sum0 for(int i0 ilt5 i) for(int
j0 jlt5 j) sumdataij
return avgsum/25 public static int
firstOddData(int data) int res0
for(int i0 ilt5 i) for(int j0 jlt5
j) if (dataij2 ! 0)
resdataij break return res
53Array and Methods
Hello Java !
public static int leastEvenData(int data)
int res0 for(int i0 ilt5 i) for(int
j0 jlt5 j) if (dataij2 0)
resdataij return res
//end class
Array Operations ---------------------------------
1- Print Main Diagonal 2- Print Secondary
Diagonal 3- Print Upper Triangle 4- Print Lower
Triangle 5- Return the Avarage 6- Return the
First Odd Data 7- Return the Least Even Data 8-
Print the Array 0- Exit ------------------------
---------- Enter your choice 0 Exit
Output
54Array and Methods
Hello Java !
Exercise12 Write a boolean method called
hasEight(), which takes an integer as input and
returns true if the number contains the digit 8
(e.g., 18, 808). The signature of the method is
as follows public static
boolean hasEight(int number)
Exercise13 Write a boolean method called
contains(), which takes an array of int and an
int and returns true if the array contains the
given int. The method's signature is as
follows public static
boolean contains(int array, int key)
Exercise14 Write a boolean method called
equals(), which takes two arrays of int and
returns true if the two arrays are exactly the
same (i.e., same length and same contents). The
method's signature is as follows
public static boolean equals(int
array1, int array2)
55Array and Methods
Hello Java !
Exercise15 Write a program called
GradesStatistics, which reads in n grades (of int
between 0 and 100, inclusive) and displays the
average, minimum, maximum, median and standard
deviation. Display the floating-point values upto
2 decimal places. Your output shall look
like Enter the number of students 4 Enter the
grade for student 1 50 Enter the grade for
student 2 51 Enter the grade for student 3
56 Enter the grade for student 4
53 50,51,56,53 The average is 52.50 The median
is 52.00 The minimum is 50 The maximum is
56 The standard deviation is 2.29 The formula
for calculating standard deviation is
56Array and Methods
Hello Java !
Exercise16 Write a method to compute e and
exp(x) using the following series expansion, in a
class called TrigonometricSeries. The signatures
of the methods are public static double exp(int
numTerms) // x in radians public static double
exp(double x, int numTerms)
End The Hello Java! Level 1
57Java Levels
Level 5
Level 4
Level 3
Level 2
Level 1
58Are you Interested to continue with us Hello
Java! Level 2
NEW
Hello Java! Level 2 OOP with Java Class,
Object, Interface ArrayList, Stack,
Queue Overloading, Overriding