please solve the following program in java scanner class
Answers
this of dn publisher book....
import java.util.*;
public class sum
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int x,n,i,j,f;
double s=0.0;
System.out.println("Enter the limit and the value of 'x' = ");
n= in.nextInt();
x=in.nextInt();
for(i=1;i<=n;i++)
{
f=1;
for(j=1;j<=i;j++)
{
f=f*j;
}
s=s+((((i-1)*x)+i)/(f*1.0));
}
System.out.print("Sum = "+s);
}
}
Answer:
import java.io.*;. //Scanner package name for java input,output and utility
import java.util.*;
class factorial //Class name//
{
public static void main(int x,int n)
{
Scanner Sc=new Scanner(System.in);
System.out.println("Enter the number of terms in the series:"); //Scanner name to initialise variables
n=Sc.nextInt();
int s=1;int f=1;int g=2;
for(int i=1; i less than equal to n;i++)
{
s=s+(i*x+(i++))/f*g;
g++;. //Loop iteration to find out the sum of the series
}
System.out.print("\n");
System.out.println("Sum of series are="+s);. //To display the sum//
}
}