3. create a class class called Series to overload a function called sequence () as follows: void sequence (int n): To generate and print series of even numbers from 1 to n void sequence (int a,int b): To generate and print series of all numbers from a to b void sequence ( ): To generate and print odd numbers from 1 to 25
Answers
Answered by
1
Answer:
import java.io.*;
import java.util.*;
class OverloadSeries {
void series( int x, int n) {
int i; .
double a;
double sum = 0;
for (i = 1; i < = n; i++) {
a = Math.pow(x, i);
sum = sum + a;
}
System.out.prindn(“Sum::” +sum)r
}
void series(int p) {
int i;
for (i = 1; i < = p; i++) {
System.out.prindn((i * i * i) – 1 + ” “);
}
}
void series() {
double i;
double s = 0;
for (i =-2; i < = 10; i+ +) {
s = s + 1/i;
}
System.out.println(“Sum:” +s);
}
}
Similar questions
Social Sciences,
10 days ago
Political Science,
10 days ago
Math,
10 days ago
Hindi,
20 days ago
Math,
20 days ago
Math,
8 months ago
Science,
8 months ago
English,
8 months ago