ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2019 ICSE Computer Science Paper



Share with a Friend

Solved 2019 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Series Overload Program - ICSE 2019 Computer Science

Design a class to overload a function series() as follows:

(a) void series(int x, int n) – to display the sum of the series given below:
x1 + x2 + x3 + … xn terms

(b) void series(int p) – to display the following series:
0, 7, 26, 63, … p terms

(c) void series() – to display the sum of the series given below:

class Overload{ public void series(int x, int n){ double s = 0.0; for(int i = 1; i <= n; i++) s += Math.pow(x, i); System.out.println("Sum = " + s); } public void series(int p){ for(int i = 1; i <= p; i++){ int x = (int)Math.pow(i, 3) - 1; System.out.print(x + " "); } System.out.println(); } public void series(){ double s = 0.0; for(int i = 2; i <= 10; i++) s += 1.0 / i; System.out.println("Sum = " + s); } }

Output