design a class to overload function series.
1)`double series(double n )
2)double series (double a ,double n)
Answers
Answered by
0
Weldmark By Tweco 14 Series Contact Tip (
Answered by
2
public class KboatSeries
{
double series(double n) {
double sum = 0;
for (int i = 1; i <= n; i++) {
double term = 1.0 / i;
sum += term;
}
return sum;
}
double series(double a, double n) {
double sum = 0;
int x = 1;
for (int i = 1; i <= n; i++) {
int e = x + 1;
double term = x / Math.pow(a, e);
sum += term;
x += 3;
}
return sum;
}
public static void main(String args[]) {
KboatSeries obj = new KboatSeries();
System.out.println("First series sum = " + obj.series(5));
System.out.println("Second series sum = " + obj.series(3, 8));
}
}
Attachments:
Similar questions
Math,
7 days ago
Math,
7 days ago
CBSE BOARD XII,
7 days ago
Computer Science,
16 days ago
World Languages,
16 days ago
Math,
8 months ago
Geography,
8 months ago
Math,
8 months ago