please for this question .its computer icse .please type the correct answer .i hope u will help me
Answers
Explanation:
import java.util.*;
class Sum_series
{
public static void main (String args [])
{
Scanner sc=new Scanner (System.in);
System.out.println("Press \n1 for 1st sum series\n2 for 2nd series");
int inp=sc.nextInt();
if (inp==1)
{
System.out.println("enter x and n\nn should be even number!");
int x=sc.nextInt();
int n=sc.nextInt();
double sum1=0;
for(int i=0;i<=n;i+=2)
{
int fact=1;
for(int j=1;j<=(x+i);j++)
fact=fact*j;
sum1=sum1+fact/(5*(i+1));
}
System.out.println("Sum of the first series:"+sum1);
}
else if (inp==2)
{
System.out.println("enter n");
int n=sc.nextInt();
double sum2=0;
for(int i=1;i<=n;i++)
{
int sum=0;
for(int j=1;j<=(i+1);j++)
sum+=j;
sum2=sum2+1.0/sum;
}
System.out.println("the sum of 2nd series:"+sum2);
}
else
System.out.println("wrong input");
}
}
Some additional information:
*if else ladder let us to present multiple choices to the user.(menu-driven approach)
*for loops are used here to re-iterate the values and add them up.