0% found this document useful (0 votes)
2 views3 pages

Class XI Java Series Programs

The document contains Java programs for Class XI Computer Project, consisting of multiple series of calculations. Each series includes different mathematical operations such as summing odd and even terms, calculating powers, and factorials. The programs utilize user input to determine the number of terms for the calculations.

Uploaded by

gudduguptatata
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)
2 views3 pages

Class XI Java Series Programs

The document contains Java programs for Class XI Computer Project, consisting of multiple series of calculations. Each series includes different mathematical operations such as summing odd and even terms, calculating powers, and factorials. The programs utilize user input to determine the number of terms for the calculations.

Uploaded by

gudduguptatata
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
You are on page 1/ 3

Java Programs - Class XI Computer Project

Series 1(a)
import java.util.Scanner;

public class Series1a {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
int sum = 0;

for (int i = 1; i <= n; i++) {


int term = (i % 2 == 0) ? 0 : (i - 1);
sum += term;
}

System.out.println("Sum = " + sum);


}
}

Series 1(b)
import java.util.Scanner;

public class Series1b {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
int sum = 0, term = 2;

for (int i = 1; i <= n; i++) {


sum += term;
term *= 2;
}

System.out.println("Sum = " + sum);


}
}

Series 1(c)
import java.util.Scanner;

public class Series1c {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
int sum = 0;

for (int i = 1; i <= n; i++) {


int term = (int)Math.pow(i, 3);
sum += term;
}

System.out.println("Sum = " + sum);


}
}

Series 2(a)
import java.util.Scanner;

public class Series2a {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
double sum = 0;

for (int i = 2; i < n + 2; i++) {


double term = 1.0 / (i * i);
sum += (i % 2 == 0) ? term : -term;
}

System.out.println("Sum = " + sum);


}
}

Series 2(b)
import java.util.Scanner;

public class Series2b {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter value of a: ");
double a = sc.nextDouble();
double sum = 1;

for (int i = 2; i <= 10; i++) {


sum += a / i;
}

System.out.println("Sum = " + sum);


}
}

Series 2(c)
public class Series2c {
public static void main(String[] args) {
int fact = 1, sumNum = 0;
double sum = 0;

for (int i = 1; i <= 10; i++) {


fact *= i;
sumNum += i;
sum += (double)fact / sumNum;
}

System.out.println("Sum = " + sum);


}
}

Series 2(d)
import java.util.Scanner;

public class Series2d {


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter value of a: ");
double a = sc.nextDouble();
System.out.print("Enter number of terms: ");
int n = sc.nextInt();
double sum = 0;

for (int i = 1; i <= n; i++) {


int power = 2 * i;
double term = Math.pow(a, power) / (2 * i);
sum += (i % 2 == 1) ? term : -term;
}

System.out.println("Sum = " + sum);


}
}

You might also like