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

Assignment 9

The Java program allows users to calculate the sum of two different mathematical series based on their input choice. If the user selects the first option, they can input a value 'a' to compute the sum of the series using the formula (a^2)/i for i from 1 to 10. The second option calculates a different series based on fixed values, resulting in a cumulative sum after 10 iterations.

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Assignment 9

The Java program allows users to calculate the sum of two different mathematical series based on their input choice. If the user selects the first option, they can input a value 'a' to compute the sum of the series using the formula (a^2)/i for i from 1 to 10. The second option calculates a different series based on fixed values, resulting in a cumulative sum after 10 iterations.

Uploaded by

tapaskumarmahato
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;

class Assignment9{

public static void main(String args[]){

Scanner in=new Scanner(System.in);

System.out.println("1. Enter 1 for Sum of 1st Series:");

System.out.println("2. Enter 2 for Sum of 2nd Series:");

System.out.print("Enter your choice:");

int choice=in.nextInt();

switch(choice){

case 1:

System.out.print("Enter the value of a:");

double a=in.nextInt();

double sum=0;

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

sum=sum+(a*a)/i;

System.out.println("Sum of Series:"+sum);

break;

case 2:

int fnum=9,snum=11,s=0;

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

s=s+fnum*snum;

fnum--;

snum--;

System.out.println("Series:"+s);

break;
default:

System.out.println("Wrong choice entered:");

Output:-

1. Enter 1 for Sum of 1st Series:

2. Enter 2 for Sum of 2nd Series:

Enter your choice: 1

Enter the value of a: 2

Sum of Series:11.715873015873015

You might also like