0% found this document useful (0 votes)
25 views4 pages

Java Series Program Examples

The document outlines various Java programming tasks focused on computing and displaying sums of different mathematical series using iterative constructs, nested loops, and user-defined methods. It includes examples of series such as factorial sums, Fibonacci sequences, and alternating series, along with instructions for implementing menu-driven programs. Each task emphasizes the use of Java programming concepts to solve specific problems related to series calculations.

Uploaded by

deepak0478
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)
25 views4 pages

Java Series Program Examples

The document outlines various Java programming tasks focused on computing and displaying sums of different mathematical series using iterative constructs, nested loops, and user-defined methods. It includes examples of series such as factorial sums, Fibonacci sequences, and alternating series, along with instructions for implementing menu-driven programs. Each task emphasizes the use of Java programming concepts to solve specific problems related to series calculations.

Uploaded by

deepak0478
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

Write a program to compute and display the sum of the

Java Series Programs following series:


[Link] S = (1 + 2) / (1 * 2) + (1 + 2 + 3) / (1 * 2 * 3) + -------- + (1
programs + 2 + 3 + ----- + n ) / (1 * 2 * 3 * ----- * n)

 Iterative Constructs in Java  Java Nested for Loops


Write a program in Java to display the first 10 terms of Write a program in Java to find the sum of the given
the following series: series:
10, 20, 30, 40, …….. S = 1! + 2! + 3! + …. + n!

 Iterative Constructs in Java  Java Nested for Loops


Write the program in Java to display the first ten terms Write a program in Java to input the values of x and n
of the following series: and print the sum of the following series:
1, 4, 9, 16, S = 1 + (x+2)/2! + (2x+3)/3! + (3x+4)/4! + ……… to n
terms
 Iterative Constructs in Java
 Iterative Constructs in Java
Write a program in Java to find the sum of the given
series: Write a program in Java to print the following series:
S = a2 + a2 / 2 + a2 / 3 + …… + a2 / 10 3, 6, 12, 24, 48, ….. to n

 Iterative Constructs in Java  Java User Defined Methods


Write a program in Java to find the sum of the given Design a class to overload a function series( ) as
series: follows:
S = a + a2 / 2 + a3 / 3 + …… + a10 / 10 (a) void series (int x, int n) – To display the sum of the
series given below:
 Iterative Constructs in Java
x1 + x2 + x3 + ………. xn terms
Write a program in Java to find the sum of the given
series: (b) void series (int p) – To display the following series:

x - x2/3 + x3/5 - x4/7 + …. to n terms 0, 7, 26, 63 ………. p terms

 Iterative Constructs in Java (c) void series () – To display the sum of the series given
below:
Using switch statement, write a menu driven program
for the following: 1/2 + 1/3 + 1/4 + ………. 1/10

(a) To find and display the sum of the series given  Java User Defined Methods
below:
Design a class to overload a method series( ) as follows:
S = x1 - x2 + x3 - x4 + x5 - ………… - x20; where x = 2
double series(double n) with one double argument and
(b) To display the series: returns the sum of the series.
sum = (1/1) + (1/2) + (1/3) + ………. + (1/n)
1, 11, 111, 1111, 11111
double series(double a, double n) with two double
For an incorrect option, an appropriate error message
arguments and returns the sum of the series.
should be displayed.
sum = (1/a2) + (4/a5) + (7/a8) + (10/a11) + ………. to n
terms
 Iterative Constructs in Java

Write the program in Java to display the first ten terms  Iterative Constructs in Java
of the following series:
Write the program in Java to display the first ten terms
1, 2, 4, 7, 11, of the following series:

3, 6, 9, 12,
 Java Nested for Loops

1
 Iterative Constructs in Java  Iterative Constructs in Java

Write the program in Java to display the first ten terms Write the program in Java to display the first ten terms
of the following series: of the following series:

4, 8, 16, 32, 24, 99, 224, 399,

 Iterative Constructs in Java  Iterative Constructs in Java

Write the program in Java to display the first ten terms Write the program in Java to display the first ten terms
of the following series: of the following series:

1.5, 3.0, 4.5, 6.0, 2, 5, 10, 17,

 Iterative Constructs in Java  Iterative Constructs in Java

Write the program in Java to display the first ten terms Write a program in Java to find the sum of the given
of the following series: series:

0, 7, 26, 1 + 4 + 9 + …… + 400

 Java Nested for Loops  Iterative Constructs in Java

Write a program in Java to print the series: Write a program in Java to find the sum of the given
series:
8, 88, 888, 8888, 88888, 888888
1 + (1/2) + (1/3) + …… + (1/20)
 Iterative Constructs in Java
 Iterative Constructs in Java
Write the program in Java to display the first ten terms
of the following series: Write a program in Java to find the sum of the given
series:
1, 9, 25, 49,
1 + (1/3) + (1/5) + …… + (1/19)
 Iterative Constructs in Java
 Iterative Constructs in Java
Write the program in Java to display the first ten terms
of the following series: Write a program in Java to find the sum of the given
series:
4, 16, 36, 64,
(1/2) + (2/3) + (3/4) + …… + (19/20)
 Iterative Constructs in Java
 Iterative Constructs in Java
Write the program in Java to display the first ten terms
of the following series: Write a program in Java to find the sum of the given
series:
0, 3, 8, 15,
2 - 4 + 6 - 8 + …… - 20
 Java User Defined Methods
 Iterative Constructs in Java
Design a class to overload a function sumSeries() as
follows: Write a program in Java to find the sum of the given
series:
(i) void sumSeries(int n, double x): with one integer
argument and one double argument to find and display (1*2) + (2*3) + …… + (19*20)
the sum of the series given below:
 Iterative Constructs in Java
𝑥 𝑥 𝑥 𝑥 𝑥
𝑠= − + − + . . . . . . . . . 𝑡𝑜 𝑛 𝑡𝑒𝑟𝑚𝑠
1 2 3 4 5 Write a program in Java to find the sum of the given
series:
(ii) void sumSeries(): to find and display the sum of the
following series: S = (a*2) + (a*3) + …… + (a*20)
𝑠 = 1 + (1 × 2) + (1 × 2 × 3)+. . . . . . . . . + (1 × 2 × 3
× 4 … . . . . . . × 20)

2
 Iterative Constructs in Java Sample Input: 15390
Sample Output: Sum of the digits = 18
Write the program to find the sum of the following
series: For an incorrect choice, an appropriate error message
should be displayed.
S = a + a2 + a3 + ……. + an
 Java Nested for Loops
 Iterative Constructs in Java
Write Java program to find the sum of the given series:
Write a program in Java to find the sum of the given
series: 1 + (1/2!) + (1/3!) + (1/4!) + ………. + (1/n!)

S = 1 + 22 / a + 33 / a2 + …… to n terms  Java Nested for Loops

 Iterative Constructs in Java Write Java program to find the sum of the given series:

Write a program in Java to find the sum of the given 1 + (1+2) + (1+2+3) + ………. + (1+2+3+ …… + n)
series:
 Java Nested for Loops
S = 12/a + 32 / a2 + 52 / a3 + …… to n terms
Write Java program to find the sum of the given series:

1 + (1*2) + (1*2*3) + ………. + (1*2*3* …… * n)


 Iterative Constructs in Java
 Java Nested for Loops
Write a program in Java to find the sum of the given
series: Write Java program to find the sum of the given series:

S = 1/a + 1/a2 + 1/a3 + …… + 1/an 1 + 1 / (1+2) + 1 / (1+2+3) + ………. + 1 / (1+2+3+…..+n)

 Iterative Constructs in Java  Java Nested for Loops

Write a program in Java to find the sum of the given Write Java program to find the sum of the given series:
series: (1/2) + (1/3) + (1/5) + (1/7) + (1/11) + ………. + (1/29)
S = x/2 + x/5 + x/8 + x/11 + …… + x/20
 Iterative Constructs in Java
 Iterative Constructs in Java Write the program in Java to display the first ten terms
Write a menu driven program to perform the following of the following series:
tasks by using Switch case statement: 0, 1, 2, 3, 6,
(a) To print the series:
 Iterative Constructs in Java
0, 3, 8, 15, 24, ………… to n terms. (value of 'n' is to be
Write the program in Java to display the first ten terms
an input by the user)
of the following series:
(b) To find the sum of the series:
1, -3, 5, -7, 9,
S = (1/2) + (3/4) + (5/6) + (7/8) + ……….. + (19/20)
 Iterative Constructs in Java
 Iterative Constructs in Java
Write the program in Java to display the first ten terms
Using a switch statement, write a menu driven program of the following series:
to:
1, 12, 123, 1234,
(a) Generate and display the first 10 terms of the
Fibonacci series
 Iterative Constructs in Java

Write the program in Java to find the sum of the


0, 1, 1, 2, 3, 5
following series:
The first two Fibonacci numbers are 0 and 1, and each
S = 1 + 1 + 2 + 3 + 5 + ……. to n terms
subsequent number is the sum of the previous two.

(b) Find the sum of the digits of an integer that is input.

3
 Iterative Constructs in Java  Java Nested for Loops

Write the program in Java to find the sum of the Write a program in Java to find the sum of the
following series: following series:

S = 2 - 4 + 6 - 8 + ……. to n S = a + (a/2!) + (a/3!) + (a/4!) + ……. + (a/n!)

 Iterative Constructs in Java  Java Nested for Loops

Write the program in Java to find the sum of the Write a program in Java to find the sum of the
following series: following series:

S = 1 + (1+2) + (1+2+3) + ……. + (1+2+3+ ……. + n) S = a - (a/2!) + (a/3!) - (a/4!) + ……. to n

 Iterative Constructs in Java  Java Nested for Loops

Write the program in Java to find the sum of the Write a program in Java to find the sum of the
following series: following series:

S = 1 + (1*2) + (1*2*3) + ……. + (1*2*3* ……. * n) S = (a/2!) - (a/3!) + (a/4!) - (a/5!) + ……. + (a/10!)

 Iterative Constructs in Java  Java Nested for Loops

Write the program to find the sum of the following Write a program in Java to input the values of x and n
series: and print the sum of the following series:

S = a + a2 + a3 + ……. + an S = 1 - x2/2! + x4/4! - x6/6! + ……. xn/n!

 Iterative Constructs in Java  Java Nested for Loops

Write the program to find the sum of the following Write a program in Java to find the sum of the
series: following series:

S = (a+1) + (a+2) + (a+3) + ……. + (a+n) S = (2/a) + (3/a2) + (5/a3) + (7/a4) + ……. to n

 Iterative Constructs in Java  Java User Defined Methods

Write the program to find the sum of the following Design a class to overload a function series( ) as
series: follows:

S = (a/2) + (a/5) + (a/8) + (a/11) + ……. + (a/20) (a) void series(int a, int n) — To display the sum of the
series given below:
 Iterative Constructs in Java
a - (a/2!) + (a/3!) - (a/4!) + …… n terms
Write the program to find the sum of the following
series: (b) void series(int n) — To display the sum of the series
given below:
S = (1/a) + (2/a2) + (3/a3) + ……. to n
1/2 - 2/3 + 3/4 - 4/5 + …… n terms
 Iterative Constructs in Java
Write a main method to create an object and invoke
Write the program to find the sum of the following the above methods.
series:
 Java User Defined Methods
S = a - a3 + a5 - a7 + ……. to n
Using switch statement write a menu driven program
 Java Nested for Loops to overload a function series as follows:

Write a program in Java to find the sum of the (a) void series() — To find and display the sum of the
following series: following series:
S = 2 - 4 + 6 - 8 + 10 ….. - 20
S = 1 + (3/2!) + (5/3!) + (7/4!) + ……. to n
(b) void series(int n, int x) — To find and display the
sum of the following series:
S = (x2 / 1!) + (x4 / 3!) + (x6 / 5!) + ……. to n terms

You might also like